[pLog-svn] r6022 - in plog/trunk: class/action/admin class/dao class/view/admin js/ui/pages locale/admin templates/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Wed Oct 31 12:34:57 EDT 2007
Author: mark
Date: 2007-10-31 12:34:57 -0400 (Wed, 31 Oct 2007)
New Revision: 6022
Added:
plog/trunk/js/ui/pages/friends.js
plog/trunk/templates/admin/editfriend_form.template
plog/trunk/templates/admin/editfriends_table.template
plog/trunk/templates/admin/newfriend_form.template
Modified:
plog/trunk/class/action/admin/adminaddfriendaction.class.php
plog/trunk/class/action/admin/admineditfriendaction.class.php
plog/trunk/class/action/admin/admineditfriendsaction.class.php
plog/trunk/class/action/admin/adminnewfriendaction.class.php
plog/trunk/class/action/admin/adminupdatefriendaction.class.php
plog/trunk/class/dao/friend.class.php
plog/trunk/class/dao/friendauthorizationstatus.class.php
plog/trunk/class/dao/friendgroup.class.php
plog/trunk/class/dao/friends.class.php
plog/trunk/class/dao/userauthorizationstatus.class.php
plog/trunk/class/view/admin/admineditfriendview.class.php
plog/trunk/class/view/admin/adminfriendslistview.class.php
plog/trunk/class/view/admin/adminnewfriendview.class.php
plog/trunk/locale/admin/locale_en_UK.php
plog/trunk/locale/admin/locale_zh_CN.php
plog/trunk/locale/admin/locale_zh_TW.php
plog/trunk/templates/admin/editfriend.template
plog/trunk/templates/admin/editfriends.template
plog/trunk/templates/admin/newfriend.template
plog/trunk/templates/admin/validate.template
Log:
Ajaxified Friend almost done! (need more works in friend delete action)
Modified: plog/trunk/class/action/admin/adminaddfriendaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddfriendaction.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/action/admin/adminaddfriendaction.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,25 +1,12 @@
<?php
- /**
- * Friend
- */
-
-
-
-
-
-
-
-
-
-
/**
* \ingroup Action
* @private
*
* Action that adds a new friend to the database.
*/
- class AdminAddFriendAction extends AdminAction
+ class AdminAddFriendAction extends AdminAction
{
var $_friendName;
var $_friendGroupId;
@@ -33,25 +20,23 @@
function AdminAddFriendAction( $actionInfo, $request )
{
$this->AdminAction( $actionInfo, $request );
-
+
// register two validators
- $this->registerFieldValidator( "friendName", new StringValidator());
- $this->registerFieldValidator( "friendGroupId", new IntegerValidator());
- $this->registerFieldValidator( "invitationText", new StringValidator());
+ $this->registerFieldValidator( "friendName", new StringValidator(), false, $this->_locale->tr("error_empty_name" ));
+ $this->registerFieldValidator( "friendGroupId", new IntegerValidator(), false, $this->_locale->tr("error_invalide_friend_group" ));
+ $this->registerFieldValidator( "invitationText", new StringValidator(), false, $this->_locale->tr("error_empty_invitation_text" ));
$this->registerField( "friendDescription" );
// and the view we should show in case there is a validation error
$errorView = new AdminNewFriendView( $this->_blogInfo );
- $errorView->setErrorMessage( $this->_locale->tr("error_adding_friend" ));
+ $errorView->setErrorMessage( $this->_locale->tr("error_adding_friend" ));
$this->setValidationErrorView( $errorView );
}
-
+
function sendInvitationEmail( $userInfo )
{
// if everything went fine, we can now send the confirmation email
// only if the user specified a valid email address
if( $userInfo->getEmail() != "" ) {
-
-
// build an email message
$message = new EmailMessage();
$message->setBody( $this->_invitationText );
@@ -62,15 +47,11 @@
$emailService = new EmailService();
$emailService->sendMessage( $message );
}
-
return true;
}
- /**
- * Carries out the specified action
- */
- function perform()
- {
+ function addFriend()
+ {
// fetch the data, we already know it's valid and that we can trust it!
$this->_friendName = Textfilter::filterAllHTML( $this->_request->getValue( "friendName" ) );
$this->_friendGroupId = $this->_request->getValue( "friendGroupId" );
@@ -79,88 +60,107 @@
// see if the user exists
if( $this->_userInfo->getUsername() == $this->_friendName ) {
- $this->_view = new AdminNewFriendView( $this->_blogInfo );
- $this->_view->setErrorMessage( $this->_locale->pr("error_invalid_user", $this->_friendName) );
- $this->_form->setFieldValidationStatus( "friendName", false );
- $this->setCommonData( true );
-
+ $this->_message = $this->_locale->pr("error_invalid_user", $this->_friendName);
return false;
}
-
+
// see if the user exists
$users = new Users();
$friendInfo = $users->getUserInfoFromUsername( $this->_friendName );
if( !$friendInfo ) {
- $this->_view = new AdminNewFriendView( $this->_blogInfo );
- $this->_view->setErrorMessage( $this->_locale->pr("error_invalid_user", $this->_friendName) );
- $this->_form->setFieldValidationStatus( "friendName", false );
- $this->setCommonData( true );
-
+ $this->_message = $this->_locale->pr("error_invalid_user", $this->_friendName);
return false;
}
-
+
// create the object...
-
$friends = new Friends();
$friendGroups = new FriendGroups();
// We need a friend's friend groups, so just pickup one.
- $friendGroup = array_pop( $friendGroups->getUserFriendGroups( $friendInfo->getId(), "", 1, 1) );
+ // TODO:: need to implement default friend group
+ $friendGroup = array_pop( $friendGroups->getUserFriendGroups( $friendInfo->getId(),
+ false,
+ "",
+ 1,
+ 1 ) );
- $userToFriend = new Friend( $this->_userInfo->getId(),
- $friendInfo->getId(),
- $this->_friendGroupId,
- $this->_friendDescription,
- USER_AUTHORIZATION_APPROVED,
- FRIEND_AUTHORIZATION_WAITING );
-
+ $userToFriend = new Friend( $this->_userInfo->getId(),
+ $friendInfo->getId(),
+ $this->_friendGroupId,
+ $this->_friendDescription,
+ USER_AUTHORIZATION_CONFIRMED,
+ FRIEND_AUTHORIZATION_WAITING );
+
// fire the pre event...
$this->notifyEvent( EVENT_PRE_ADD_FRIEND, Array( "friend" => &$userToFriend ));
// once we have built the object, we can add it to the database!
- $this->_view = new AdminFriendsListView( $this->_blogInfo );
- if( $friends->addFriend( $userToFriend ) ) {
- // if everything went fine, transfer the execution flow to the action that
- // lists all the article categories... without forgetting that we should let the
- // next class know that we actually added a topic alongside a message
- // and the topic that we just added!
+ $result = $friends->addFriend( $userToFriend );
+ if( $result ) {
$friendToUser = $friends->getFriendByUserIdAndFriendId( $friendInfo->getId(), $this->_userInfo->getId() );
if ( !empty($friendToUser) ) {
$friendToUser->setUserAuthorizationStatus(USER_AUTHORIZATION_WAITING);
- $friendToUser->setFriendAuthorizationStatus(FRIEND_AUTHORIZATION_APPROVED);
+ $friendToUser->setFriendAuthorizationStatus(FRIEND_AUTHORIZATION_CONFIRMED);
$friends->updateFriend( $friendToUser );
} else {
- $friendToUser = new Friend( $friendInfo->getId(),
- $this->_userInfo->getId(),
- $friendGroup->getId(),
- "",
- USER_AUTHORIZATION_WAITING,
- FRIEND_AUTHORIZATION_APPROVED );
+ $friendToUser = new Friend( $friendInfo->getId(),
+ $this->_userInfo->getId(),
+ $friendGroup->getId(),
+ "",
+ USER_AUTHORIZATION_WAITING,
+ FRIEND_AUTHORIZATION_CONFIRMED );
$friends->addFriend( $friendToUser );
}
- $this->_view->setSuccess( true );
- $this->_view->setSuccessMessage( $this->_locale->pr( "friend_added_ok", $friendInfo->getUsername() ) );
-
+ $this->_message = $this->_locale->pr( "friend_added_ok", $friendInfo->getUsername() );
+
// fire the post event
$this->notifyEvent( EVENT_POST_ADD_FRIEND, Array( "friend" => &$userToFriend ));
-
$this->sendInvitationEmail( $friendInfo );
-
CacheControl::resetBlogCache( $this->_blogInfo->getId());
-
- $this->setCommonData();
+ } else {
+ $this->_message = $this->_locale->tr("error_adding_friend" );
+ }
+
+ $this->_friend = $userToFriend;
+
+ return( $result );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ $this->_view = new AdminFriendsListView( $this->_blogInfo );
+
+ $result = $this->addFriend();
+
+ if( !$result ) {
+ // set an error message
+ $this->_view->setErrorMessage( $this->_message);
}
- else {
- // if there was an error, we should say so... as well as not changing the view since
- // we're going back to the original view where we can add the topic
- $this->_view->setError( true );
- $this->_view->setErrorMessage( $this->_locale->tr("error_adding_friend" ));
- $this->setCommonData( true );
- }
+ else {
+ // or success
+ $this->_view->setSuccessMessage( $this->_message );
+ }
- // better to return true if everything fine
+ $this->setCommonData();
+
return true;
}
+
+ function performAjax()
+ {
+ $result = $this->addFriend();
+
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+
+ $this->_view->setSuccess( $result );
+ $this->_view->setMessage( $this->_message );
+ $this->_view->setResult( $this->_friend );
+
+ return( true );
+ }
}
?>
\ No newline at end of file
Modified: plog/trunk/class/action/admin/admineditfriendaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditfriendaction.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/action/admin/admineditfriendaction.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,15 +1,5 @@
<?php
- /**
- * Friend
- */
-
-
-
-
-
-
-
/**
* \ingroup Action
* @private
@@ -37,30 +27,45 @@
$this->registerField( "friendGroupId" );
$this->registerField( "friendDescription" );
// and the view we should show in case there is a validation error
- $errorView = new AdminEditFriendView( $this->_blogInfo );
+ $errorView = new AdminFriendsListView( $this->_blogInfo );
$errorView->setErrorMessage( $this->_locale->tr("error_incorrect_friend_id" ));
$this->setValidationErrorView( $errorView );
}
+ function loadFriend()
+ {
+ // fetch the link
+ $this->_friendId = $this->_request->getValue( "friendId" );
+ $friends = new Friends();
+ $friend = $friends->getFriend( $this->_friendId, $this->_userInfo->getId() );
+ // show an error if we couldn't fetch the link
+ if( !$friend ) {
+ return false;
+ }
+
+ $this->notifyEvent( EVENT_FRIEND_LOADED, Array( "friend" => &$friend ) );
+
+ return( $friend );
+ }
+
/**
* Carries out the specified action
*/
function perform()
{
- // fetch the topic
- $this->_friendId = $this->_request->getValue( "friendId" );
- $friends = new Friends();
- $friend = $friends->getFriend( $this->_friendId, $this->_userInfo->getId() );
- // show an error if we couldn't fetch the topic
+ $friend = $this->loadFriend();
if( !$friend ) {
- $this->_view = new AdminFriendssListView( $this->_blogInfo );
- $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_friend") );
- $this->_view->setError( true );
+
+ if( $this->_request->isXHR())
+ $this->_view = new AdminErrorDialogView( $this->_blogInfo );
+ else
+ $this->_view = new AdminFriendsListView( $this->_blogInfo );
+
+ $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_friend" ));
$this->setCommonData();
return false;
}
- $this->notifyEvent( EVENT_FRIEND_LOADED, Array( "friend" => &$friend ) );
// otherwise show the form to edit its fields
$friendInfo = $friend->getFriendInfo();
$this->_view = new AdminEditFriendView( $this->_blogInfo );
@@ -83,5 +88,10 @@
// better to return true if everything fine
return true;
}
+
+ function performAjax()
+ {
+ return( $this->perform());
+ }
}
?>
Modified: plog/trunk/class/action/admin/admineditfriendsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditfriendsaction.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/action/admin/admineditfriendsaction.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,10 +1,4 @@
<?php
- /**
- * Friend
- */
-
-
-
/**
* \ingroup Action
@@ -12,7 +6,7 @@
*
* Action that shows a form to add a link for the blogroll feature
*/
- class AdminEditFriendsAction extends adminaction
+ class AdminEditFriendsAction extends adminaction
{
/**
@@ -22,11 +16,15 @@
function AdminEditFriendsAction( $actionInfo, $request )
{
$this->AdminAction( $actionInfo, $request );
-
+
$this->registerFieldValidator( "showGroup", new IntegerValidator(), true);
- $this->setValidationErrorView( new AdminFriendsListView( $this->_blogInfo,
+ $this->setValidationErrorView( new AdminFriendsListView( $this->_blogInfo,
Array( "showGroup" => 0,
"searchTerms" => "" )));
+
+ // get the id of the group we'd like to load
+ $this->_groupId = $this->_request->getValue( "showGroup" );
+ $this->_searchTerms = $this->_request->getValue( "searchTerms" );
}
/**
@@ -34,10 +32,6 @@
*/
function perform()
{
- // get the id of the category we'd like to load
- $this->_groupId = $this->_request->getValue( "showGroup" );
- $this->_searchTerms = $this->_request->getValue( "searchTerms" );
-
// create the view, which will take care of fetching the right data
$this->_view = new AdminFriendsListView( $this->_blogInfo, Array( "showGroup" => $this->_groupId,
"searchTerms" => $this->_searchTerms ));
@@ -46,5 +40,23 @@
// better to return true if everything fine
return true;
}
+
+ /**
+ * Ajax-specific behaviour
+ */
+ function performAjax()
+ {
+ if( $this->_request->getOutput() == Request::REQUEST_OUTPUT_JSON ) {
+ $friendsListView = new AdminFriendsListView( $this->_blogInfo, Array( "showGroup" => $this->_groupId,
+ "searchTerms" => $this->_searchTerms ));
+ $friendsListView->loadData();
+
+ $this->_view = new AjaxViewRenderer( $friendsListView );
+ $this->_view->setResultObject( "friends" );
+ }
+ else {
+ return( $this->perform());
+ }
+ }
}
-?>
+?>
\ No newline at end of file
Modified: plog/trunk/class/action/admin/adminnewfriendaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminnewfriendaction.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/action/admin/adminnewfriendaction.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,19 +1,12 @@
<?php
- /**
- * Friend
- */
-
-
-
-
/**
* \ingroup Action
* @private
*
* Action that adds a new friend to the database
*/
- class AdminNewFriendAction extends AdminAction
+ class AdminNewFriendAction extends AdminAction
{
/**
@@ -33,5 +26,10 @@
$this->_view = new AdminNewFriendView( $this->_blogInfo );
$this->setCommonData();
}
+
+ function performAjax()
+ {
+ return( $this->perform());
+ }
}
?>
\ No newline at end of file
Modified: plog/trunk/class/action/admin/adminupdatefriendaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdatefriendaction.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/action/admin/adminupdatefriendaction.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,15 +1,4 @@
<?php
- /**
- * Friend
- */
-
-
-
-
-
-
-
-
/**
* \ingroup Action
@@ -36,8 +25,8 @@
// register two validators
$this->registerFieldValidator( "friendId", new IntegerValidator());
- $this->registerFieldValidator( "friendName", new StringValidator());
- $this->registerFieldValidator( "friendGroupId", new IntegerValidator());
+ $this->registerFieldValidator( "friendName", new StringValidator(), $this->_locale->tr( "error_empty_name" ));
+ $this->registerFieldValidator( "friendGroupId", new IntegerValidator(), $this->_locale->tr( "error_group_id" ));
$this->registerField( "friendDescription" );
$this->registerField( "userAuthorizationStatus" );
// and the view we should show in case there is a validation error
@@ -46,25 +35,28 @@
$this->setValidationErrorView( $errorView );
}
- /**
- * Carries out the specified action
- */
- function perform()
- {
+ function updateFriend()
+ {
+ // data is fine, we have already validated it
+ $f = new HtmlFilter();
+
// fetch the data, we already know it's valid and that we can trust it!
$this->_friendId = $this->_request->getValue( "friendId" );
- $this->_friendName = Textfilter::filterAllHTML( $this->_request->getValue( "friendName" ) );
+ $this->_friendName = $this->_request->getValue( "friendName", $f );
$this->_friendGroupId = $this->_request->getValue( "friendGroupId" );
- $this->_friendDescription = Textfilter::filterAllHTML( $this->_request->getValue( "friendDescription" ) );
+ $this->_friendDescription = $this->_request->getValue( "friendDescription", $f);
$this->_userAuthorizationStatus = $this->_request->getValue( "userAuthorizationStatus" );
-
+
+ // fetch the link we're trying to update
// initial the friends object
$friends = new Friends();
$friend = $friends->getFriend( $this->_friendId, $this->_userInfo->getId() );
-
- $this->_view = new AdminFriendsListView( $this->_blogInfo );
+ if( !$friend ) {
+ $this->_message = $this->_locale->tr( "error_fetching_friend" );
+ return false;
+ }
- // If the user reject the invitation request, the we need to delete both friends data
+ // If the user reject the invitation request, then we need to delete both friends
if( $this->_userAuthorizationStatus == USER_AUTHORIZATION_REJECT )
{
// fire the pre event
@@ -72,28 +64,28 @@
if( $friends->deleteFriendByUserIdAndFriendId( $friend->getUserId(), $friend->getFriendId() ) &&
$friends->deleteFriendByUserIdAndFriendId( $friend->getFriendId(), $friend->getUserId() ) )
{
- $this->_view->setSuccessMessage( $this->_locale->pr( "friend_deleted_ok", $friend->getUsername() ) );
+ $friend->setUserAuthorizationStatus( USER_AUTHORIZATION_REJECT );
+ $friendInfo = $friend->getFriendInfo();
+ $this->_message = $this->_locale->pr( "friend_deleted_ok", $friendInfo->getUsername() );
+
// fire the post event
$this->notifyEvent( EVENT_POST_DELETE_FRIEND, Array( "friend" => &$friend ));
CacheControl::resetBlogCache( $this->_blogInfo->getId());
-
- $this->setCommonData();
+ return $friend;
} else {
- $this->_view->setError( true );
- $this->_view->setErrorMessage( $this->_locale->tr("error_updating_friend" ));
- $this->setCommonData( true );
+ $this->_message = $this->_locale->tr("error_updating_friend" );
+ return false;
}
-
} else {
// fire the pre-event
$this->notifyEvent( EVENT_PRE_UPDATE_FRIEND, Array( "friend" => &$friend ));
if ( $friend->getUserAuthorizationStatus() == USER_AUTHORIZATION_WAITING &&
- $this->_userAuthorizationStatus == USER_AUTHORIZATION_APPROVED )
+ $this->_userAuthorizationStatus == USER_AUTHORIZATION_CONFIRMED )
{
$friendToUser = $friends->getFriendByUserIdAndFriendId( $friend->getFriendId(), $friend->getUserId() );
- $friendToUser->setFriendAuthorizationStatus( FRIEND_AUTHORIZATION_APPROVED );
+ $friendToUser->setFriendAuthorizationStatus( FRIEND_AUTHORIZATION_CONFIRMED );
}
// update the object content
@@ -112,22 +104,56 @@
if( $success ) {
$friendInfo = $friend->getFriendInfo();
- $this->_view->setSuccessMessage( $this->_locale->pr("friend_updated_ok", $friendInfo->getUsername()));
+ $this->_message = $this->_locale->pr( "friend_updated_ok", $friendInfo->getUsername() );
// fire the post-event
$this->notifyEvent( EVENT_POST_UPDATE_FRIEND, Array( "friend" => &$friend ) );
// clear the cache
- CacheControl::resetBlogCache( $this->_blogInfo->getId());
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+ return $friend;
} else {
- $this->_view->setErrorMessage( $this->_locale->tr("error_updating_friend") );
+ $this->_message = $this->_locale->tr("error_updating_friend");
+ return false;
}
-
- $this->setCommonData();
-
- // better to return true if everything fine
- return true;
}
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ if(( $friend = $this->updateFriend())) {
+ $this->_view = new AdminFriendsListView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_message );
+ $this->setCommonData();
+ }
+ else {
+ // and go back to the view with the list of links
+ $this->_view = new AdminFriendsListView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_message );
+ $this->setCommonData();
+ }
+
+ // better to return true if everything fine
+ return true;
}
+
+ function performAjax()
+ {
+
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+ if(( $friend = $this->updateFriend())) {
+ $this->_view->setSuccess( true );
+ $this->_view->setResult( $friend );
+ }
+ else {
+ $this->_view->setSuccess( false );
+ }
+ $this->_view->setMessage( $this->_message );
+
+ return( true );
+ }
}
?>
Modified: plog/trunk/class/dao/friend.class.php
===================================================================
--- plog/trunk/class/dao/friend.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/dao/friend.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,9 +1,7 @@
<?php
-
-
-
-
+ lt_include( PLOG_CLASS_PATH."class/dao/userauthorizationstatus.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/friendauthorizationstatus.class.php" );
/**
* \ingroup DAO
@@ -34,7 +32,7 @@
* @param friendAuthorizationStatus
*/
function Friend( $userId, $friendId, $groupId = 0 , $description = "",
- $userAuthorizationStatus = USER_AUTHORIZATION_APPROVED, $friendAuthorizationStatus = FRIEND_AUTHORIZATION_APPROVED, $id = -1)
+ $userAuthorizationStatus = USER_AUTHORIZATION_CONFIRMED, $friendAuthorizationStatus = FRIEND_AUTHORIZATION_CONFIRMED, $id = -1)
{
$this->DbObject();
@@ -211,4 +209,4 @@
}
}
}
-?>
\ No newline at end of file
+?>
Modified: plog/trunk/class/dao/friendauthorizationstatus.class.php
===================================================================
--- plog/trunk/class/dao/friendauthorizationstatus.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/dao/friendauthorizationstatus.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,9 +1,7 @@
<?php
-
-
define( "FRIEND_AUTHORIZATION_ALL", -1, true );
- define( "FRIEND_AUTHORIZATION_APPROVED", 1, true );
+ define( "FRIEND_AUTHORIZATION_CONFIRMED", 1, true );
define( "FRIEND_AUTHORIZATION_WAITING", 2, true );
define( "FRIEND_AUTHORIZATION_REJECT", 3, true );
Modified: plog/trunk/class/dao/friendgroup.class.php
===================================================================
--- plog/trunk/class/dao/friendgroup.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/dao/friendgroup.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -136,15 +136,15 @@
* @param status A valid post status
* @return An integer value
*/
- function getNumFriends( $userAuthorizationStatus = USER_AUTHORIZATION_APPROVED, $friendAuthorizationStatus = FRIEND_AUTHORIZATION_APPROVED )
+ function getNumFriends( $userAuthorizationStatus = USER_AUTHORIZATION_CONFIRMED, $friendAuthorizationStatus = FRIEND_AUTHORIZATION_CONFIRMED )
{
if( $userAuthorizationStatus == USER_AUTHORIZATION_ALL && $friendAuthorizationStatus == FRIEND_AUTHORIZATION_ALL )
return( $this->_numFriends );
- elseif( $userAuthorizationStatus == USER_AUTHORIZATION_WAITING && $friendAuthorizationStatus == FRIEND_AUTHORIZATION_APPROVED )
+ elseif( $userAuthorizationStatus == USER_AUTHORIZATION_WAITING && $friendAuthorizationStatus == FRIEND_AUTHORIZATION_CONFIRMED )
return( $this->_numWaitingFriends );
- elseif( $userAuthorizationStatus == USER_AUTHORIZATION_APPROVED && $friendAuthorizationStatus == FRIEND_AUTHORIZATION_WAITING )
+ elseif( $userAuthorizationStatus == USER_AUTHORIZATION_CONFIRMED && $friendAuthorizationStatus == FRIEND_AUTHORIZATION_WAITING )
return( $this->_numPendingFriends );
- elseif( $userAuthorizationStatus == USER_AUTHORIZATION_APPROVED && $friendAuthorizationStatus == FRIEND_AUTHORIZATION_APPROVED )
+ elseif( $userAuthorizationStatus == USER_AUTHORIZATION_CONFIRMED && $friendAuthorizationStatus == FRIEND_AUTHORIZATION_CONFIRMED )
return( $this->_numAuthorizedFriends );
else {
@@ -162,7 +162,7 @@
function getNumAuthorizedFriends()
{
- return( $this->getNumFriends( USER_AUTHORIZATION_APPROVED, FRIEND_AUTHORIZATION_APPROVED ));
+ return( $this->getNumFriends( USER_AUTHORIZATION_CONFIRMED, FRIEND_AUTHORIZATION_CONFIRMED ));
}
function setNumAuthorizedFriends( $numAuthorizedFriends )
@@ -174,7 +174,7 @@
function getNumWaitingFriends()
{
- return( $this->getNumFriends( USER_AUTHORIZATION_WAITING, FRIEND_AUTHORIZATION_APPROVED ));
+ return( $this->getNumFriends( USER_AUTHORIZATION_WAITING, FRIEND_AUTHORIZATION_CONFIRMED ));
}
function setNumWaitingFriends( $numWaitingFriends )
@@ -186,7 +186,7 @@
function getNumPendingFriends()
{
- return( $this->getNumFriends( USER_AUTHORIZATION_APPROVED, FRIEND_AUTHORIZATION_WAITING ));
+ return( $this->getNumFriends( USER_AUTHORIZATION_CONFIRMED, FRIEND_AUTHORIZATION_WAITING ));
}
function setNumPendingFriends( $numPendingFriends )
Modified: plog/trunk/class/dao/friends.class.php
===================================================================
--- plog/trunk/class/dao/friends.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/dao/friends.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,9 +1,5 @@
<?php
-
-
-
-
/**
* \ingroup DAO
*
@@ -91,9 +87,9 @@
if( $newGroup ) {
$newGroup->setNumFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$newGroup->getId()));
- $newGroup->setNumAuthorizedFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$newGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_APPROVED.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_APPROVED ));
- $newGroup->setNumWaitingFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$newGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_WAITING.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_APPROVED ));
- $newGroup->setNumPendingFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$newGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_APPROVED.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_WAITING ));
+ $newGroup->setNumAuthorizedFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$newGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_CONFIRMED.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_CONFIRMED ));
+ $newGroup->setNumWaitingFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$newGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_WAITING.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_CONFIRMED ));
+ $newGroup->setNumPendingFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$newGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_CONFIRMED.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_WAITING ));
$groups->updateFriendGroup( $newGroup );
}
@@ -102,9 +98,9 @@
if ($oldGroup)
{
$oldGroup->setNumFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$oldGroup->getId()));
- $oldGroup->setNumAuthorizedFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$oldGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_APPROVED.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_APPROVED ));
- $oldGroup->setNumWaitingFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$oldGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_WAITING.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_APPROVED ));
- $oldGroup->setNumPendingFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$oldGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_APPROVED.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_WAITING ));
+ $oldGroup->setNumAuthorizedFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$oldGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_CONFIRMED.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_CONFIRMED ));
+ $oldGroup->setNumWaitingFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$oldGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_WAITING.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_CONFIRMED ));
+ $oldGroup->setNumPendingFriends($this->getNumItems( $this->getPrefix().'friends', 'group_id = '.$oldGroup->getId().' AND user_authorization_status = '.USER_AUTHORIZATION_CONFIRMED.' AND friend_authorization_status = '.FRIEND_AUTHORIZATION_WAITING ));
$groups->updateFriendGroup( $oldGroup );
}
}
Modified: plog/trunk/class/dao/userauthorizationstatus.class.php
===================================================================
--- plog/trunk/class/dao/userauthorizationstatus.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/dao/userauthorizationstatus.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,9 +1,7 @@
<?php
-
-
define( "USER_AUTHORIZATION_ALL", -1, true );
- define( "USER_AUTHORIZATION_APPROVED", 1, true );
+ define( "USER_AUTHORIZATION_CONFIRMED", 1, true );
define( "USER_AUTHORIZATION_WAITING", 2, true );
define( "USER_AUTHORIZATION_REJECT", 3, true );
Modified: plog/trunk/class/view/admin/admineditfriendview.class.php
===================================================================
--- plog/trunk/class/view/admin/admineditfriendview.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/view/admin/admineditfriendview.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,12 +1,5 @@
<?php
-
- /**
- * Friend
- */
-
-
-
/**
* \ingroup View
* @private
@@ -21,7 +14,10 @@
*/
function AdminEditFriendView( $blogInfo, $params = Array())
{
- $this->AdminTemplatedView( $blogInfo, "editfriend" );
+ if( Request::isXHR())
+ $this->AdminTemplatedView( $blogInfo, "editfriend_form" );
+ else
+ $this->AdminTemplatedView( $blogInfo, "editfriend" );
}
function render()
Modified: plog/trunk/class/view/admin/adminfriendslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminfriendslistview.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/view/admin/adminfriendslistview.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,20 +1,12 @@
<?php
- /**
- * Friend
- */
-
-
-
-
-
/**
* \ingroup View
* @private
*
* Action that shows a form to add a link for the blogroll feature
*/
- class AdminFriendsListView extends AdminTemplatedView
+ class AdminFriendsListView extends AdminTemplatedView
{
var $_page;
@@ -24,69 +16,72 @@
*/
function AdminFriendsListView( $blogInfo, $params = Array())
{
- $this->AdminTemplatedView( $blogInfo, "editfriends" );
-
- // save the parameters and put them in a nicer place after checking them
- if( isset( $params["showGroup"] ))
- $this->_request->setValue( "showGroup", $params["showGroup"] );
+ if( Request::isXHR())
+ $this->AdminTemplatedView( $blogInfo, "editfriends_table" );
else
- $this->_request->setValue( "showGroup", 0 );
+ $this->AdminTemplatedView( $blogInfo, "editfriends" );
- if( isset( $params["searchTerms"] ))
- $this->_request->setValue( "searchTerms", $params["searchTerms"] );
- else
- $this->_request->setValue( "searchTerms", 0 );
+ // save the parameters and put them in a nicer place after checking them
+ if( !isset( $params["showGroup"] ) ) $params["showGroup"] = 0;
+ if( !isset( $params["searchTerms"] ) ) $params["searchTerms"] = "";
+
+ $this->setValue( "showGroup", $params["showGroup"] );
+ $this->setValue( "searchTerms", $params["searchTerms"] );
+ $this->_page = $this->getCurrentPageFromRequest();
}
- /**
- * Carries out the specified action
- */
- function render()
- {
- $groupId = $this->_request->getValue( "showGroup");
- $searchTerms = $this->_request->getValue( "searchTerms" );
+ function loadData()
+ {
+ // get the parameters
+ $this->_groupId = $this->getValue( "showGroup");
+ $this->_searchTerms = $this->getValue( "searchTerms" );
// prepare a few parameters
$friends = new Friends();
-
- // get the page too
- $this->_page = $this->getCurrentPageFromRequest();
-
+
// retrieve the friends in an paged fashion
- $totalFriends = $friends->getNumFriends( $this->_userInfo->getId(), $groupId );
- $userFriends = $friends->getFriends( $this->_userInfo->getId(),
- $groupId,
- -1,
- -1,
- $searchTerms,
- $this->_page,
+ $totalFriends = $friends->getNumFriends( $this->_userInfo->getId(), $this->_groupId );
+
+ // the pager that will be used
+ $pager = new Pager( "?op=editFriends&searchTerms=".$this->_searchTerms."&page=",
+ $this->_page,
+ $totalFriends,
+ DEFAULT_ITEMS_PER_PAGE );
+ $this->setValue( "pager", $pager );
+
+ $userFriends = $friends->getFriends( $this->_userInfo->getId(),
+ $this->_groupId,
+ -1,
+ -1,
+ $this->_searchTerms,
+ $this->_page,
DEFAULT_ITEMS_PER_PAGE );
-
- if( !$userFriends ) {
- $userFriends = Array();
- }
-
+
// throw the even in case somebody's waiting for it!
$this->notifyEvent( EVENT_FRIENDS_LOADED, Array( "friends" => &$userFriends ));
-
+ // put the friends in the view
+ $this->setValue( "friends", $userFriends );
+ $this->setValue( "pager", $pager );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function render()
+ {
+ $this->loadData();
+
$friendGroups = new FriendGroups();
$groups = $friendGroups->getUserFriendGroups( $this->_userInfo->getId() );
$this->notifyEvent( EVENT_FRIEND_GROUPS_LOADED, Array ( "friendgroups" => &$groups ));
- $this->setValue( "friends", $userFriends );
$this->setValue( "friendgroups", $groups );
- $this->setValue( "currentgroup", $groupId );
+ $this->setValue( "currentgroup", $this->_groupId );
$this->setValue( "userAuthorizationStatusList", UserAuthorizationStatus::getStatusList() );
$this->setValue( "friendAuthorizationStatusList", FriendAuthorizationStatus::getStatusList() );
-
- // the pager that will be used
- $pager = new Pager( "?op=editFriends&searchTerms=".$searchTerms."&page=",
- $this->_page,
- $totalFriends,
- DEFAULT_ITEMS_PER_PAGE );
- $this->setValue( "pager", $pager );
- parent::render();
+
+ parent::render();
}
}
-?>
+?>
\ No newline at end of file
Modified: plog/trunk/class/view/admin/adminnewfriendview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminnewfriendview.class.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/class/view/admin/adminnewfriendview.class.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,19 +1,12 @@
<?php
- /**
- * Friend
- */
-
-
-
-
/**
* \ingroup View
* @private
*
* Action that shows a form to add a friend
*/
- class AdminNewFriendView extends AdminTemplatedView
+ class AdminNewFriendView extends AdminTemplatedView
{
/**
* Constructor. If nothing else, it also has to call the constructor of the parent
@@ -21,9 +14,12 @@
*/
function AdminNewFriendView( $blogInfo, $params = Array())
{
- $this->AdminTemplatedView( $blogInfo, "newfriend" );
+ if( Request::isXHR() )
+ $this->AdminTemplatedView( $blogInfo, "newfriend_form" );
+ else
+ $this->AdminTemplatedView( $blogInfo, "newfriend" );
}
-
+
function render()
{
// get all the friend groups
Added: plog/trunk/js/ui/pages/friends.js
===================================================================
--- plog/trunk/js/ui/pages/friends.js (rev 0)
+++ plog/trunk/js/ui/pages/friends.js 2007-10-31 16:34:57 UTC (rev 6022)
@@ -0,0 +1,38 @@
+Lifetype.UI.Pages.Friends = function() {}
+
+Lifetype.UI.Pages.Friends.addSubmitHook = function( form )
+{
+ Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json', {resetAfterSuccess:true} );
+}
+
+Lifetype.UI.Pages.Friends.updateSubmitHook = function( form )
+{
+ Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json' );
+}
+
+Lifetype.UI.Pages.Friends.updateForm = function( type, args )
+{
+ var o = args[0];
+ var response = Lifetype.JSon.decode( o.responseText );
+ var result = response.result;
+ var field = Lifetype.Dom.$( 'userAuthorizationStatus' );
+ if( field )
+ {
+ if ( result.user_authorization_status == 1 ) {
+ field.parentNode.removeChild( field );
+ } else if ( result.user_authorization_status == 3 ) {
+ Lifetype.UI.OverlayManager.getActive().hide();
+ }
+ }
+}
+
+YAHOO.util.Event.addListener( window, "load", function() {
+ var t = new Lifetype.Effects.Table( "list" );
+ t.stripe();
+ t.highlightRows();
+
+ // reload the list when successfully deleting an item and processing one of the forms
+ Lifetype.Forms.Events.performRequestSuccessEvent.subscribe( Lifetype.UI.AjaxPager.reload );
+ Lifetype.Forms.Events.formProcessorSuccessEvent.subscribe( Lifetype.UI.AjaxPager.reload );
+ Lifetype.Forms.Events.formProcessorSuccessEvent.subscribe( Lifetype.UI.Pages.Friends.updateForm );
+});
\ No newline at end of file
Modified: plog/trunk/locale/admin/locale_en_UK.php
===================================================================
--- plog/trunk/locale/admin/locale_en_UK.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/locale/admin/locale_en_UK.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1230,14 +1230,14 @@
// edit friend
$messages['editFriends'] = 'Edit Friends';
$messages['editFriend'] = 'Edit Friend';
-$messages['user_authorization_status'] = 'Your Approval';
-$messages['user_authorization_status_help'] = 'Your friend are waiting for your approval.';
-$messages['user_authorization_approved'] = 'Approved';
+$messages['user_authorization_status'] = 'Your Confirmation';
+$messages['user_authorization_status_help'] = 'Your friend are waiting for your confirmation.';
+$messages['user_authorization_approved'] = 'confirmed';
$messages['user_authorization_waiting'] = 'Waiting';
$messages['user_authorization_reject'] = 'Reject';
-$messages['friend_authorization_status'] = 'Friend\'s Approval';
-$messages['friend_authorization_status_help'] = 'You are waiting for your friend\'s approval.';
-$messages['friend_authorization_approved'] = 'Approved';
+$messages['friend_authorization_status'] = 'Friend\'s Confirmation';
+$messages['friend_authorization_status_help'] = 'You are waiting for your friend\'s confirmation.';
+$messages['friend_authorization_approved'] = 'Confirmed';
$messages['friend_authorization_waiting'] = 'Waiting';
$messages['friend_authorization_reject'] = 'Reject';
$messages['friend_group'] = 'Friend Group';
Modified: plog/trunk/locale/admin/locale_zh_CN.php
===================================================================
--- plog/trunk/locale/admin/locale_zh_CN.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/locale/admin/locale_zh_CN.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1249,12 +1249,12 @@
$messages['editFriend'] = '编辑好友';
$messages['user_authorization_status'] = '你的审核';
$messages['user_authorization_status_help'] = '你的好友正在等在你的审核中。';
-$messages['user_authorization_approved'] = '确认';
+$messages['user_authorization_confirmed'] = '确认';
$messages['user_authorization_waiting'] = '等待';
$messages['user_authorization_reject'] = '拒绝';
$messages['friend_authorization_status'] = '好友审核';
$messages['friend_authorization_status_help'] = '你正在等待你的好友审核中。';
-$messages['friend_authorization_approved'] = '确认';
+$messages['friend_authorization_confirmed'] = '确认';
$messages['friend_authorization_waiting'] = '等待';
$messages['friend_authorization_reject'] = '拒绝';
$messages['friend_group'] = '好友群组';
Modified: plog/trunk/locale/admin/locale_zh_TW.php
===================================================================
--- plog/trunk/locale/admin/locale_zh_TW.php 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/locale/admin/locale_zh_TW.php 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1249,12 +1249,12 @@
$messages['editFriend'] = '編輯好友';
$messages['user_authorization_status'] = '你的審核';
$messages['user_authorization_status_help'] = '你的好友正在等在你的審核中。';
-$messages['user_authorization_approved'] = '確認';
+$messages['user_authorization_confirmed'] = '確認';
$messages['user_authorization_waiting'] = '等待';
$messages['user_authorization_reject'] = '拒絕';
$messages['friend_authorization_status'] = '好友審核';
$messages['friend_authorization_status_help'] = '你正在等待你的好友審核中。';
-$messages['friend_authorization_approved'] = '確認';
+$messages['friend_authorization_confirmed'] = '確認';
$messages['friend_authorization_waiting'] = '等待';
$messages['friend_authorization_reject'] = '拒絕';
$messages['friend_group'] = '好友群組';
Modified: plog/trunk/templates/admin/editfriend.template
===================================================================
--- plog/trunk/templates/admin/editfriend.template 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/templates/admin/editfriend.template 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,71 +1,7 @@
{include file="$admintemplatepath/header.template"}
{include file="$admintemplatepath/navigation.template" showOpt=editFriends title=$locale->tr("editFriend")}
- <form name="editFriend" action="admin.php" method="post">
+{include file="$admintemplatepath/editfriend_form.template"}
- <fieldset class="inputField">
- <legend>{$locale->tr("editFriend")}</legend>
- {include file="$admintemplatepath/formvalidate.template" message=$locale->tr("error_updating_friend")}
-
- <div class="field">
- <label for="friendName">{$locale->tr("name")}</label>
- <span class="required">*</span>
- <div class="formHelp">{$locale->tr("friend_name_help")}</div>
- <input type="text" id="friendName" name="friendName" value="{$friendName|escape:"html"}" readonly="readonly" />
- {include file="$admintemplatepath/validate.template" field=friendName message=$locale->tr("error_empty_name")}
- </div>
-
- {if !empty( $userAuthorizationStatus )}
- <div class="field">
- <label for="userAuthorizationStatus">{$locale->tr("user_authorization_status")}</label>
- <span class="required">*</span>
- <div class="formHelp">{$locale->tr("user_authorization_status_help")}</div>
- <select name="userAuthorizationStatus" id="userAuthorizationStatus">
- {foreach from=$userAuthorizationStatusList key=name item=status}
- <option value="{$status}" {if $userAuthorizationStatus == $status} selected="selected"{/if}>{$locale->tr($name)}</option>
- {/foreach}
- </select>
- </div>
- {else}
- {if $friendAuthorizationStatus}
- <div class="field">
- <label for="friendAuthorizationStatus">{$locale->tr("friend_authorization_status")}</label>
- <span class="required">*</span>
- <div class="formHelp">{$locale->tr("friend_authorization_status_help")}</div>
- <input type="text" id="friendAuthorizationStatus" name="friendAuthorizationStatus" value="{$locale->tr("friend_authorization_waiting")}" readonly />
- </div>
- {/if}
- {/if}
-
- <div class="field">
- <label for="friendGroupId">{$locale->tr("group")}</label>
- <span class="required">*</span>
- <div class="formHelp">{$locale->tr("friend_group_help")}</div>
- <select name="friendGroupId" id="friendGroupId">
- {foreach from=$friendgroups item=friendGroup}
- <option value="{$friendGroup->getId()}" {if $friendGroupId == $friendGroup->getId()}selected="selected"{/if}>
- {$friendGroup->getName()}
- </option>
- {/foreach}
- </select>
- </div>
-
- <div class="field">
- <label for="friendDescription">{$locale->tr("description")}</label>
- <span class="required"></span>
- <div class="formHelp">{$locale->tr("friend_description_help")}</div>
- <textarea name="friendDescription" id="friendDescription" cols="60" rows="5">{$friendDescription}</textarea>
- {include file="$admintemplatepath/validate.template" field=friendDescription message=$locale->tr("error_empty_description")}
- </div>
-
- </fieldset>
- <div class="buttons">
- <input type="reset" name="resetButton" value="{$locale->tr("reset")}" />
- <input type="submit" name="Update" value="{$locale->tr("update")}" />
- <input type="hidden" name="op" value="updateFriend" />
- <input type="hidden" name="friendId" value="{$friendId}" />
- </div>
-</form>
-
{include file="$blogtemplate/footernavigation.template"}
{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
Added: plog/trunk/templates/admin/editfriend_form.template
===================================================================
--- plog/trunk/templates/admin/editfriend_form.template (rev 0)
+++ plog/trunk/templates/admin/editfriend_form.template 2007-10-31 16:34:57 UTC (rev 6022)
@@ -0,0 +1,65 @@
+ <form id="editFriend" action="admin.php" method="post" onSubmit="Lifetype.UI.Pages.Friends.updateSubmitHook(this);return(false);">
+
+ <fieldset class="inputField">
+ <legend>{$locale->tr("editFriend")}</legend>
+ {include file="$admintemplatepath/formvalidateajax.template"}
+
+ <div class="field">
+ <label for="friendName">{$locale->tr("name")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("friend_name_help")}</div>
+ <input type="text" id="friendName" name="friendName" value="{$friendName|escape:"html"}" readonly="readonly" />
+ {include file="$admintemplatepath/validateajax.template" field=friendName}
+ </div>
+
+ {if !empty( $userAuthorizationStatus )}
+ <div id="userAuthorizationStatus" class="field">
+ <label for="userAuthorizationStatus">{$locale->tr("user_authorization_status")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("user_authorization_status_help")}</div>
+ <select name="userAuthorizationStatus" id="userAuthorizationStatus">
+ {foreach from=$userAuthorizationStatusList key=name item=status}
+ <option value="{$status}" {if $userAuthorizationStatus == $status} selected="selected"{/if}>{$locale->tr($name)}</option>
+ {/foreach}
+ </select>
+ </div>
+ {else}
+ {if $friendAuthorizationStatus}
+ <div class="field">
+ <label for="friendAuthorizationStatus">{$locale->tr("friend_authorization_status")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("friend_authorization_status_help")}</div>
+ <input type="text" id="friendAuthorizationStatus" name="friendAuthorizationStatus" value="{$locale->tr("friend_authorization_waiting")}" readonly />
+ </div>
+ {/if}
+ {/if}
+
+ <div class="field">
+ <label for="friendGroupId">{$locale->tr("group")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("friend_group_help")}</div>
+ <select name="friendGroupId" id="friendGroupId">
+ {foreach from=$friendgroups item=friendGroup}
+ <option value="{$friendGroup->getId()}" {if $friendGroupId == $friendGroup->getId()}selected="selected"{/if}>
+ {$friendGroup->getName()}
+ </option>
+ {/foreach}
+ </select>
+ {include file="$admintemplatepath/validateajax.template" field=friendGroupId}
+ </div>
+
+ <div class="field">
+ <label for="friendDescription">{$locale->tr("description")}</label>
+ <span class="required"></span>
+ <div class="formHelp">{$locale->tr("friend_description_help")}</div>
+ <textarea name="friendDescription" id="friendDescription" cols="60" rows="5">{$friendDescription}</textarea>
+ </div>
+
+ </fieldset>
+ <div class="buttons">
+ <input type="reset" name="resetButton" value="{$locale->tr("reset")}" />
+ <input type="submit" name="Update" value="{$locale->tr("update")}" />
+ <input type="hidden" name="op" value="updateFriend" />
+ <input type="hidden" name="friendId" value="{$friendId}" />
+ </div>
+</form>
\ No newline at end of file
Modified: plog/trunk/templates/admin/editfriends.template
===================================================================
--- plog/trunk/templates/admin/editfriends.template 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/templates/admin/editfriends.template 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,99 +1,50 @@
{include file="$admintemplatepath/header.template"}
{include file="$admintemplatepath/navigation.template" showOpt=editFriends title=$locale->tr("editFriends")}
-
+{js src="js/ui/pages/friends.js"}
<div id="list_nav_bar">
-<div id="list_nav_select">
-
+ <div id="list_nav_select">
<form id="vieFriends" action="admin.php" method="post">
<fieldset>
<legend>{$locale->tr("show_by")}</legend>
- <div class="list_nav_option">
+ <div class="list_nav_option">
<label for="showGroup">{$locale->tr("friend_group")}</label>
- <br />
- <select name="showGroup" id="showGroup">
- <option value="0">{$locale->tr("category_all")}</option>
- {foreach from=$friendgroups item=friendGroup}
+ <br />
+ <select name="showGroup" id="showGroup">
+ <option value="0">{$locale->tr("category_all")}</option>
+ {foreach from=$friendgroups item=friendGroup}
<option value="{$friendGroup->getId()}" {if $currentgroup == $friendGroup->getId()} selected="selected" {/if}>{$friendGroup->getName()}</option>
- {/foreach}
+ {/foreach}
</select>
- </div>
-
- <div class="list_nav_option">
- <label for="search">{$locale->tr("search_terms")}</label>
- <br />
- <input type="text" name="searchTerms" value="{$searchTerms}" size="15" id="search" />
- </div>
-
- <div class="list_nav_option">
+ </div>
+ <div class="list_nav_option">
+ <label for="search">{$locale->tr("search_terms")}</label>
<br />
+ <input type="text" name="searchTerms" value="{$searchTerms}" size="15" id="search" />
+ </div>
+ <div class="list_nav_option">
+ <br />
<input type="hidden" name="op" value="editFriends" />
<input type="submit" name="Show" value="{$locale->tr("show")}" />
- </div>
- </fieldset>
- </form>
- </div>
- <br style="clear:both" />
- </div>
+ </div>
+ </fieldset>
+</form>
+ </div>
+ <br style="clear:both" />
+</div>
- <form id="deleteFriends" action="admin.php" method="post">
+<div class="extraFunctions">
+<div class="left">
+ <a id="newFriendButton" href="?op=newFriend" rel="overlay">{$locale->tr("newFriend")}</a>
+</div>
+<br style="clear:both" />
+</div>
+
+ <form id="deleteFriends" action="admin.php" method="post" onSubmit="Lifetype.Forms.performRequest(this);return(false);>
+ {include file="$admintemplatepath/viewvalidateajax.template"}
<div id="list">
- {include file="$admintemplatepath/successmessage.template"}
- {include file="$admintemplatepath/errormessage.template"}
- <table class="info">
- <thead>
- <tr>
- <th style="width:10px;"><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="Lifetype.Forms.toggleAllChecks('deleteFriends');" /></th>
- <th style="width:110px;">{$locale->tr("friend")}</th>
- <th style="width:160px;">{$locale->tr("blog")}</th>
- <th style="width:110px;">{$locale->tr("group")}</th>
- <th style="width:110px;">{$locale->tr("user_authorization_status")}</th>
- <th style="width:110px;">{$locale->tr("friend_authorization_status")}</th>
- <th style="width:95px;">{$locale->tr("actions")}</th>
- </tr>
- </thead>
- <tbody>
- {foreach from=$friends item=friend}
- {assign var=friendInfo value=$friend->getFriendInfo()}
- <tr class="{cycle values="odd, even"}">
- <td>
- <input class="checkbox" type="checkbox" name="friendIds[{counter}]" id="checks_{$friend->getId()}" value="{$friend->getId()}" />
- </td>
- <td class="col_highlighted">
- <a href="admin.php?op=editFriend&friendId={$friend->getId()}">{$friendInfo->getUsername()}</a>
- </td>
- <td>
- {foreach from=$friendInfo->getBlogs() item=friendBlog}
- {assign var=url value=$friendBlog->getBlogRequestGenerator()}
- <a href="{$url->blogLink()}">{$friendBlog->getBlog()}</a><br/>
- {/foreach}
- </td>
- <td>
- {assign var=group value=$friend->getGroup()}
- <a href="admin.php?op=editFriends&showGroup={$group->getId()}">{$group->getName()}</a>
- </td>
- <td>
- {foreach from=$userAuthorizationStatusList key=name item=status}
- {if $friend->getUserAuthorizationStatus() == $status}{$locale->tr($name)}{/if}
- {/foreach}
- </td>
- <td>
- {foreach from=$friendAuthorizationStatusList key=name item=status}
- {if $friend->getFriendAuthorizationStatus() == $status}{$locale->tr($name)}{/if}
- {/foreach}
- </td>
- <td>
- <div class="list_action_button">
- <a href="?op=editFriend&friendId={$friend->getId()}"><img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" /></a>
- <a href="?op=deleteFriend&friendId={$friend->getId()}"><img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" /></a>
- </div>
- </td>
- </tr>
- {/foreach}
- </tbody>
- </table>
+ {include file="$admintemplatepath/editfriends_table.template"}
</div>
<div id="list_action_bar">
- {adminpager style=list}
<input type="hidden" name="op" value="deleteFriends"/>
<input type="submit" name="Delete selected" value="{$locale->tr("delete")}"/>
</div>
Added: plog/trunk/templates/admin/editfriends_table.template
===================================================================
--- plog/trunk/templates/admin/editfriends_table.template (rev 0)
+++ plog/trunk/templates/admin/editfriends_table.template 2007-10-31 16:34:57 UTC (rev 6022)
@@ -0,0 +1,49 @@
+<table id="friends" class="info" summary="{$locale->tr("editFriends")}">
+ <thead>
+ <tr>
+ <th><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="Lifetype.Forms.toggleAllChecks('deleteFriends');" /></th>
+ <th style="width:15%;">{$locale->tr("friend")}</th>
+ <th style="width:30%;">{$locale->tr("blog")}</th>
+ <th style="width:15%;">{$locale->tr("group")}</th>
+ <th style="width:15%;">{$locale->tr("user_authorization_status")}</th>
+ <th style="width:15%;">{$locale->tr("friend_authorization_status")}</th>
+ <th style="width:10%;">{$locale->tr("actions")}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach from=$friends item=friend}
+ {assign var=friendInfo value=$friend->getFriendInfo()}
+ <tr>
+ <td align="center"><input class="checkbox" type="checkbox" name="friendIds[{counter}]" value="{$friend->getId()}" /></td>
+ <td class="col_highlighted"><a href="admin.php?op=editFriend&friendId={$friend->getId()}" rel="overlay">{$friendInfo->getUsername()}</a></td>
+ <td>
+ {foreach from=$friendInfo->getBlogs() item=friendBlog}
+ {assign var=url value=$friendBlog->getBlogRequestGenerator()}
+ <a href="{$url->blogLink()}">{$friendBlog->getBlog()}</a><br/>
+ {/foreach}
+ </td>
+ <td>
+ {assign var=group value=$friend->getGroup()}
+ <a href="admin.php?op=editFriends&showGroup={$group->getId()}">{$group->getName()}</a>
+ </td>
+ <td>
+ {foreach from=$userAuthorizationStatusList key=name item=status}
+ {if $friend->getUserAuthorizationStatus() == $status}{$locale->tr($name)}{/if}
+ {/foreach}
+ </td>
+ <td>
+ {foreach from=$friendAuthorizationStatusList key=name item=status}
+ {if $friend->getFriendAuthorizationStatus() == $status}{$locale->tr($name)}{/if}
+ {/foreach}
+ </td>
+ <td>
+ <div class="list_action_button">
+ <a rel="overlay" href="?op=editFriend&friendId={$friend->getId()}"><img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" /></a>
+ <a href="?op=deleteFriend&friendId={$friend->getId()}" onClick="Lifetype.Forms.performRequest(this);return(false)"><img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" /></a>
+ </div>
+ </td>
+ </tr>
+ {/foreach}
+</tbody>
+</table>
+{adminpagerajax style=list}
\ No newline at end of file
Modified: plog/trunk/templates/admin/newfriend.template
===================================================================
--- plog/trunk/templates/admin/newfriend.template 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/templates/admin/newfriend.template 2007-10-31 16:34:57 UTC (rev 6022)
@@ -1,56 +1,7 @@
{include file="$admintemplatepath/header.template"}
-{include file="$admintemplatepath/navigation.template" showOpt=newFriend title=$locale->tr("newFriend")}
-{if $smarty.request.friendName}
- {assign var=friendName value=$smarty.request.friendName}
-{/if}
- <form name="addFriend" method="post" action="admin.php">
- <fieldset class="inputField">
- <legend>{$locale->tr("newFriend")}</legend>
- {include file="$admintemplatepath/formvalidate.template" message=$locale->tr("error_adding_friend")}
-
- <div class="field">
- <label for="friendName">{$locale->tr("name")}</label>
- <span class="required">*</span><br/>
- <div class="formHelp">{$locale->tr("friend_name_help")}</div>
- <input type="text" value="{$friendName}" id="friendName" name="friendName"/>
- {include file="$admintemplatepath/validate.template" field=friendName message=$locale->tr("error_empty_name")}
- </div>
-
- <div class="field">
- <label for="friendGroupId">{$locale->tr("group")}</label>
- <span class="required">*</span>
- <div class="formHelp">{$locale->tr("friend_group_help")}</div>
- <select name="friendGroupId" id="friendGroupId">
- {foreach from=$friendgroups item=friendGroup}
- <option value="{$friendGroup->getId()}" {if $friendGroupId == $friendGroup->getId()}selected="selected"{/if}>
- {$friendGroup->getName()}
- </option>
- {/foreach}
- </select>
- </div>
-
- <div class="field">
- <label for="friendDescription">{$locale->tr("description")}</label>
- <span class="required"></span>
- <div class="formHelp">{$locale->tr("friend_description_help")}</div>
- <textarea name="friendDescription" cols="60" id="friendDescription" rows="5">{$friendDescription}</textarea>
- {include file="$admintemplatepath/validate.template" field=friendDescription message=$locale->tr("error_empty_description")}
- </div>
-
- <div class="field">
- <label for="invitationText">{$locale->tr("invitation_text")}</label>
- <span class="required"></span>
- <div class="formHelp">{$locale->tr("invitation_text_help")}</div>
- <textarea rows="10" cols="70" id="invitationText" name="invitationText">{if empty($invitationText)}{$locale->tr("default_invitation_text")}{else}{$invitationText}{/if}</textarea>
- {include file="$admintemplatepath/validate.template" field=invitationText message=$locale->tr("error_empty_text")}
- </div>
-
- </fieldset>
- <div class="buttons">
- <input type="hidden" name="op" value="addFriend" />
- <input type="reset" name="resetButton" value="{$locale->tr("reset")}" />
- <input type="submit" name="Add" value="{$locale->tr("add")}" />
- </div>
- </form>
-{include file="$blogtemplate/footernavigation.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=editFriends title=$locale->tr("newFriend")}
+
+{include file="$admintemplatepath/newfriend_form.template"}
+
+{include file="$admintemplatepath/footernavigation.template"}
{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
Added: plog/trunk/templates/admin/newfriend_form.template
===================================================================
--- plog/trunk/templates/admin/newfriend_form.template (rev 0)
+++ plog/trunk/templates/admin/newfriend_form.template 2007-10-31 16:34:57 UTC (rev 6022)
@@ -0,0 +1,44 @@
+<form id="addFriend" method="post" action="admin.php" onSubmit="Lifetype.UI.Pages.Friends.addSubmitHook(this);return(false);">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("newFriend")}</legend>
+ {include file="$admintemplatepath/formvalidateajax.template"}
+ <div class="field">
+ <label for="friendName">{$locale->tr("name")}</label>
+ <span class="required">*</span><br/>
+ <div class="formHelp">{$locale->tr("friend_name_help")}</div>
+ <input type="text" value="{$friendName}" id="friendName" name="friendName"/>
+ {include file="$admintemplatepath/validateajax.template" field=friendName}
+ </div>
+ <div class="field">
+ <label for="friendGroupId">{$locale->tr("group")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("friend_group_help")}</div>
+ <select name="friendGroupId" id="friendGroupId">
+ {foreach from=$friendgroups item=friendGroup}
+ <option value="{$friendGroup->getId()}" {if $friendGroupId == $friendGroup->getId()}selected="selected"{/if}>
+ {$friendGroup->getName()}
+ </option>
+ {/foreach}
+ </select>
+ {include file="$admintemplatepath/validateajax.template" field=friendGroupId}
+ </div>
+ <div class="field">
+ <label for="friendDescription">{$locale->tr("description")}</label>
+ <span class="required"></span>
+ <div class="formHelp">{$locale->tr("friend_description_help")}</div>
+ <textarea name="friendDescription" cols="60" id="friendDescription" rows="2">{$friendDescription}</textarea>
+ </div>
+ <div class="field">
+ <label for="invitationText">{$locale->tr("invitation_text")}</label>
+ <span class="required"></span>
+ <div class="formHelp">{$locale->tr("invitation_text_help")}</div>
+ <textarea rows="5" cols="70" id="invitationText" name="invitationText">{if empty($invitationText)}{$locale->tr("default_invitation_text")}{else}{$invitationText}{/if}</textarea>
+ {include file="$admintemplatepath/validateajax.template" field=invitationText}
+ </div>
+ </fieldset>
+ <div class="buttons">
+ <input type="hidden" name="op" value="addFriend" />
+ <input type="reset" name="resetButton" value="{$locale->tr("reset")}" />
+ <input type="submit" name="Add" value="{$locale->tr("add")}" />
+ </div>
+ </form>
\ No newline at end of file
Modified: plog/trunk/templates/admin/validate.template
===================================================================
--- plog/trunk/templates/admin/validate.template 2007-10-31 16:31:57 UTC (rev 6021)
+++ plog/trunk/templates/admin/validate.template 2007-10-31 16:34:57 UTC (rev 6022)
@@ -4,6 +4,6 @@
<div class="fieldValidationError">
<span style="background:red;color:white;font-weight:bold"> ! </span>
{if $mesage != ""}{$message}{else}{$form->getFieldErrorMessage($field)}{/if}
- </div>
+ </div>
{/if}
{/if}
\ No newline at end of file
More information about the pLog-svn
mailing list