[pLog-svn] r5531 - in plog/trunk: class/action/admin class/controller class/view/admin templates/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Tue Jun 12 07:12:45 EDT 2007
Author: mark
Date: 2007-06-12 07:12:44 -0400 (Tue, 12 Jun 2007)
New Revision: 5531
Added:
plog/trunk/class/action/admin/adminaddfriendaction.class.php
plog/trunk/class/action/admin/admindeletefriendaction.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/view/admin/admineditfriendview.class.php
plog/trunk/class/view/admin/adminfriendslistview.class.php
plog/trunk/class/view/admin/adminnewfriendview.class.php
plog/trunk/templates/admin/editfriend.template
plog/trunk/templates/admin/editfriends.template
plog/trunk/templates/admin/newfriend.template
Modified:
plog/trunk/class/controller/admincontrollermap.properties.php
plog/trunk/templates/admin/menus.xml
Log:
Commit the Admin Panel for friend object. It is still under development/porting.
So, don't use it at this moment.
Added: plog/trunk/class/action/admin/adminaddfriendaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddfriendaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/adminaddfriendaction.class.php 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,168 @@
+<?php
+
+ /**
+ * Friend
+ */
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/friendgroups.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminfriendslistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminnewfriendview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
+
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Action that adds a new friend to the database.
+ */
+ class AdminAddFriendAction extends AdminAction
+ {
+ var $_friendName;
+ var $_friendGroupId;
+ var $_friendDescription;
+ var $_invitationText;
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminAddFriendAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ // register two validators
+ $this->registerFieldValidator( "friendName", new StringValidator());
+ $this->registerFieldValidator( "friendGroupId", new IntegerValidator());
+ $this->registerFieldValidator( "friendDescription", new StringValidator());
+ $this->registerFieldValidator( "invitationText", new StringValidator());
+ // 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" ));
+ $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() != "" ) {
+ include_once( PLOG_CLASS_PATH."class/mail/emailservice.class.php" );
+
+ // build an email message
+ $message = new EmailMessage();
+ $message->setBody( $this->_invitationText );
+ $message->setSubject( "StarBlog Notification: Friend Invitation Message!" );
+ $message->addTo( $userInfo->getEmail());
+ $message->setFrom( $this->_userInfo->getEmail());
+ // and finally send it
+ $emailService = new EmailService();
+ $emailService->sendMessage( $message );
+ }
+
+ return true;
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ // 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" );
+ $this->_friendDescription = Textfilter::filterAllHTML( $this->_request->getValue( "friendDescription" ) );
+ $this->_invitationText = Textfilter::filterAllHTML( $this->_request->getValue( "invitationText" ) );
+
+ // 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 );
+
+ 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 );
+
+ return false;
+ }
+
+ // create the object...
+ include_once( PLOG_CLASS_PATH."class/dao/friends.class.php" );
+ $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) );
+
+ $userToFriend = new Friend( $this->_userInfo->getId(),
+ $friendInfo->getId(),
+ $this->_friendGroupId,
+ $this->_friendDescription,
+ USER_AUTHORIZATION_APPROVED,
+ 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!
+ $friendToUser = $friends->getFriendByUserIdAndFriendId( $friendInfo->getId(), $this->_userInfo->getId() );
+ if ( !empty($friendToUser) ) {
+ $friendToUser->setUserAuthorizationStatus(USER_AUTHORIZATION_WAITING);
+ $friendToUser->setFriendAuthorizationStatus(FRIEND_AUTHORIZATION_APPROVED);
+ $friends->updateFriend( $friendToUser );
+ } else {
+ $friendToUser = new Friend( $friendInfo->getId(),
+ $this->_userInfo->getId(),
+ $friendGroup->getId(),
+ "",
+ 0,
+ 0,
+ USER_AUTHORIZATION_WAITING,
+ FRIEND_AUTHORIZATION_APPROVED );
+ $friends->addFriend( $friendToUser );
+ }
+
+ $this->_view->setSuccess( true );
+ $this->_view->setSuccessMessage( $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 {
+ // 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 );
+ }
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/action/admin/admindeletefriendaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletefriendaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/admindeletefriendaction.class.php 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,100 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/friends.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminfriendslistview.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Action that shows a form to change the settings of the current blog.
+ */
+ class AdminDeleteFriendAction extends AdminAction
+ {
+
+ var $_friendIds;
+ var $_op;
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminDeleteFriendAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ $this->_op = $actionInfo->getActionParamValue();
+
+ $view = new AdminFriendsListView( $this->_blogInfo );
+ if( $this->_op == "deleteFriend" ) {
+ $this->registerFieldValidator( "friendId", new IntegerValidator());
+ $view->setErrorMessage( $this->_locale->tr("error_incorrect_friend_id"));
+ }
+ else {
+ $this->registerFieldValidator( "friendIds", new ArrayValidator());
+ $view->setErrorMessage( $this->_locale->tr("error_no_friends_selected"));
+ }
+ $this->setValidationErrorView( $view );
+
+ }
+
+ function perform()
+ {
+ if( $this->_op == "deleteFriend" ) {
+ $this->_friendIds = Array();
+ $this->_friendId = $this->_request->getValue( "friendId" );
+ $this->_friendIds[] = $this->_friendId;
+ }
+ else
+ $this->_friendIds = $this->_request->getValue( "friendIds" );
+
+ $this->_deleteFriends();
+ }
+
+ /**
+ * Carries out the specified action
+ * @private
+ */
+ function _deleteFriends()
+ {
+ // delete the friend
+ $friends = new Friends();
+
+ $errorMessage = "";
+ $successMessage = "";
+ $numOk = 0;
+ foreach( $this->_friendIds as $friendId ) {
+ // load the friend
+ $friend = $friends->getFriend( $friendId, $this->_userInfo->getId());
+ if( $friend ) {
+ if( !$friends->deleteFriend( $friendId, $this->_userInfo->getId()))
+ $errorMessage .= $this->_locale->pr("error_removing_friend", $friend->getUsername())."<br/>";
+ else {
+ $numOk++;
+ if( $numOk > 1 )
+ $successMessage = $this->_locale->pr("friends_deleted_ok", $numOk );
+ else
+ $successMessage = $this->_locale->pr("friend_deleted_ok", $friend->getUsername());
+ }
+ }
+ else {
+ $errorMessage .= $this->_locale->pr("error_removing_friend2", $friendId)."<br/>";
+ }
+ }
+
+ $this->_view = new AdminFriendsListView( $this->_blogInfo );
+ if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
+ if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage );
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+?>
Added: plog/trunk/class/action/admin/admineditfriendaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditfriendaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/admineditfriendaction.class.php 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,86 @@
+<?php
+ /**
+ * Friend
+ */
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/admineditfriendview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminfriendslistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/friendgroups.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Action that shows a form to change the settings of the article topic
+ */
+ class AdminEditFriendAction extends AdminAction
+ {
+
+ var $_friendId;
+ var $_friendName;
+ var $_friendGroupId;
+ var $_friendDescription;
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminEditFriendAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ // register two validators
+ $this->registerFieldValidator( "friendId", new IntegerValidator());
+ $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->setErrorMessage( $this->_locale->tr("error_incorrect_friend_id" ));
+ $this->setValidationErrorView( $errorView );
+ }
+
+ /**
+ * 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
+ if( !$friend ) {
+ $this->_view = new AdminFriendssListView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_friend") );
+ $this->_view->setError( true );
+ $this->setCommonData();
+ return false;
+ }
+
+ $this->notifyEvent( EVENT_FRIEND_LOADED, Array( "friend" => &$friend ) );
+ // otherwise show the form to edit its fields
+ $this->_view = new AdminEditFriendView( $this->_blogInfo );
+ $this->_view->setValue( "friendName", $friend->getUsername() );
+ $this->_view->setValue( "friendGroupId", $friend->getGroupId() );
+ $this->_view->setValue( "friendDescription", $friend->getDescription() );
+ $this->_view->setValue( "friendId", $this->_friendId );
+
+ if( $friend->getUserAuthorizationStatus() == USER_AUTHORIZATION_WAITING )
+ {
+ $this->_view->setValue( "userAuthorizationStatus", $friend->getAuthorizationStatus() );
+ $this->_view->setValue( "userAuthorizationStatusList", UserAuthorizationStatus::getStatusList() );
+ }
+
+ if( $friend->getFriendAuthorizationStatus() == FRIEND_AUTHORIZATION_WAITING )
+ $this->_view->setValue( "friendAuthorizationStatus", $friend->getFriendAuthorizationStatus() );
+
+ $this->setCommonData();
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+?>
Added: plog/trunk/class/action/admin/admineditfriendsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditfriendsaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/admineditfriendsaction.class.php 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,50 @@
+<?php
+ /**
+ * Friend
+ */
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminfriendslistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Action that shows a form to add a link for the blogroll feature
+ */
+ class AdminEditFriendsAction extends adminaction
+ {
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminEditFriendsAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ $this->registerFieldValidator( "showGroup", new IntegerValidator(), true);
+ $this->setValidationErrorView( new AdminFriendsListView( $this->_blogInfo,
+ Array( "showGroup" => 0,
+ "searchTerms" => "" )));
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ 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 ));
+ $this->setCommonData();
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+?>
Added: plog/trunk/class/action/admin/adminnewfriendaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminnewfriendaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/adminnewfriendaction.class.php 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,37 @@
+<?php
+ /**
+ * Friend
+ */
+
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminnewfriendview.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Action that adds a new friend to the database
+ */
+ class AdminNewFriendAction extends AdminAction
+ {
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminNewFriendAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ $this->_view = new AdminNewFriendView( $this->_blogInfo );
+ $this->setCommonData();
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/action/admin/adminupdatefriendaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdatefriendaction.class.php (rev 0)
+++ plog/trunk/class/action/admin/adminupdatefriendaction.class.php 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,132 @@
+<?php
+ /**
+ * Friend
+ */
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/friendgroups.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/friends.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/admineditfriendview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminfriendslistview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
+ /**
+ * \ingroup Action
+ * @private
+ *
+ * Updates an article topic.
+ */
+ class AdminUpdateFriendAction extends AdminAction
+ {
+
+ var $_friendId;
+ var $_friendName;
+ var $_friendGroupId;
+ var $_friendDescription;
+ var $_userAuthorizationStatus;
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminUpdateFriendAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+
+ // register two validators
+ $this->registerFieldValidator( "friendId", new IntegerValidator());
+ $this->registerFieldValidator( "friendName", new StringValidator());
+ $this->registerFieldValidator( "friendGroupId", new IntegerValidator());
+ $this->registerFieldValidator( "friendDescription", new StringValidator());
+ $this->registerField( "userAuthorizationStatus" );
+ // and the view we should show in case there is a validation error
+ $errorView = new AdminEditFriendView( $this->_blogInfo );
+ $errorView->setErrorMessage( $this->_locale->tr("error_updating_friend" ));
+ $this->setValidationErrorView( $errorView );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ // 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->_friendGroupId = $this->_request->getValue( "friendGroupId" );
+ $this->_friendDescription = Textfilter::filterAllHTML( $this->_request->getValue( "friendDescription" ) );
+ $this->_userAuthorizationStatus = $this->_request->getValue( "userAuthorizationStatus" );
+
+ // initial the friends object
+ $friends = new Friends();
+ $friend = $friends->getFriend( $this->_friendId, $this->_userInfo->getId() );
+
+ $this->_view = new AdminFriendsListView( $this->_blogInfo );
+
+ // If the user reject the invitation request, the we need to delete both friends data
+ if( $this->_userAuthorizationStatus == USER_AUTHORIZATION_REJECT )
+ {
+ // fire the pre event
+ $this->notifyEvent( EVENT_PRE_DELETE_FRIEND, Array( "friend" => &$friend ));
+ if( $friends->deleteFriendByUserIdAndFriendId( $friend->getUserId(), $friend->getFriendId() ) &&
+ $friends->deleteFriendByUserIdAndFriendId( $friend->getFriendId(), $friend->getUserId() ) )
+ {
+ $this->_view->setSuccessMessage( $this->_locale->pr( "friend_deleted_ok", $friend->getUsername() ) );
+
+ // fire the post event
+ $this->notifyEvent( EVENT_POST_DELETE_FRIEND, Array( "friend" => &$friend ));
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ $this->setCommonData();
+ } else {
+ $this->_view->setError( true );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_friend" ));
+ $this->setCommonData( true );
+ }
+
+ } 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 )
+ {
+ $friendToUser = $friends->getFriendByUserIdAndFriendId( $friend->getFriendId(), $friend->getUserId() );
+ $friendToUser->setFriendAuthorizationStatus( FRIEND_AUTHORIZATION_APPROVED );
+ }
+
+ // update the object content
+ $friend->setGroupId( $this->_friendGroupId );
+ $friend->setDescription( $this->_friendDescription );
+ if ( !empty( $this->_userAuthorizationStatus ) )
+ $friend->setUserAuthorizationStatus( $this->_userAuthorizationStatus );
+
+ $success = true;
+ if ( !$friends->updateFriend( $friend ) )
+ $success = false;
+
+ if ( isset( $friendToUser ) )
+ if ( !$friends->updateFriend( $friendToUser ) )
+ $success = false;
+
+ if( $success ) {
+ $this->_view->setSuccessMessage( $this->_locale->pr("friend_updated_ok", $friend->getUsername()));
+
+ // fire the post-event
+ $this->notifyEvent( EVENT_POST_UPDATE_FRIEND, Array( "friend" => &$friend ) );
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+ } else {
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_friend") );
+ }
+
+ $this->setCommonData();
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+ }
+?>
Modified: plog/trunk/class/controller/admincontrollermap.properties.php
===================================================================
--- plog/trunk/class/controller/admincontrollermap.properties.php 2007-06-12 09:30:14 UTC (rev 5530)
+++ plog/trunk/class/controller/admincontrollermap.properties.php 2007-06-12 11:12:44 UTC (rev 5531)
@@ -333,7 +333,7 @@
$actions['addLocation'] = 'AdminAddLocationAjaxAction';
// shows a window with all the friends action
$actions["friendNetwork"] = "AdminFriendNetworkAction";
- // add this for friend relationship.
+ // add this for friend group
$actions["newFriendGroup"] = "AdminNewFriendGroupAction";
$actions["addFriendGroup"] = "AdminAddFriendGroupAction";
$actions["editFriendGroups"] = "AdminEditFriendGroupsAction";
@@ -341,4 +341,12 @@
$actions["deleteFriendGroups"] = "AdminDeleteFriendGroupAction";
$actions["deleteFriendGroup"] = "AdminDeleteFriendGroupAction";
$actions["updateFriendGroup"] = "AdminUpdateFriendGroupAction";
+ // add this for friend
+ $actions["newFriend"] = "AdminNewFriendAction";
+ $actions["addFriend"] = "AdminAddFriendAction";
+ $actions["editFriends"] = "AdminEditFriendsAction";
+ $actions["editFriend"] = "AdminEditFriendAction";
+ $actions["deleteFriends"] = "AdminDeleteFriendAction";
+ $actions["deleteFriend"] = "AdminDeleteFriendAction";
+ $actions["updateFriend"] = "AdminUpdateFriendAction";
?>
\ No newline at end of file
Added: plog/trunk/class/view/admin/admineditfriendview.class.php
===================================================================
--- plog/trunk/class/view/admin/admineditfriendview.class.php (rev 0)
+++ plog/trunk/class/view/admin/admineditfriendview.class.php 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,40 @@
+<?php
+
+ /**
+ * Friend
+ */
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/friendgroups.class.php" );
+
+ /**
+ * \ingroup View
+ * @private
+ *
+ * Action that shows a form to add a link for the blogroll feature
+ */
+ class AdminEditFriendView extends AdminTemplatedView
+ {
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminEditFriendView( $blogInfo, $params = Array())
+ {
+ $this->AdminTemplatedView( $blogInfo, "editfriend" );
+ }
+
+ function render()
+ {
+ // get all the friend groups
+ $friendGroups = new FriendGroups();
+ $groups = $friendGroups->getUserFriendGroups( $this->_userInfo->getId() );
+ $this->notifyEvent( EVENT_FRIEND_RELATIONSHIPS_LOADED, Array( "friendgroups" => &$groups ));
+
+ // put the data in the view
+ $this->setValue( "friendgroups", $groups );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/view/admin/adminfriendslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminfriendslistview.class.php (rev 0)
+++ plog/trunk/class/view/admin/adminfriendslistview.class.php 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,92 @@
+<?php
+
+ /**
+ * Friend
+ */
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/friends.class.php" );
+ include_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
+
+ /**
+ * \ingroup View
+ * @private
+ *
+ * Action that shows a form to add a link for the blogroll feature
+ */
+ class AdminFriendsListView extends AdminTemplatedView
+ {
+ var $_page;
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ 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"] );
+ else
+ $this->_request->setValue( "showGroup", 0 );
+
+ if( isset( $params["searchTerms"] ))
+ $this->_request->setValue( "searchTerms", $params["searchTerms"] );
+ else
+ $this->_request->setValue( "searchTerms", 0 );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function render()
+ {
+ $groupId = $this->_request->getValue( "showGroup");
+ $searchTerms = $this->_request->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,
+ 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 ));
+
+
+ $friendGroups = new FriendGroups();
+ $groups = $friendGroups->getUserFriendGroups( $this->_userInfo->getId() );
+ $this->notifyEvent( EVENT_FRIEND_RELATIONSHIPS_LOADED, Array ( "friendgroups" => &$groups ));
+
+ $this->setValue( "friends", $userFriends );
+ $this->setValue( "friendgroups", $groups );
+ $this->setValue( "currentgroup", $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();
+ }
+ }
+?>
Added: plog/trunk/class/view/admin/adminnewfriendview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminnewfriendview.class.php (rev 0)
+++ plog/trunk/class/view/admin/adminnewfriendview.class.php 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,40 @@
+<?php
+
+ /**
+ * Friend
+ */
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/friendgroups.class.php" );
+
+ /**
+ * \ingroup View
+ * @private
+ *
+ * Action that shows a form to add a friend
+ */
+ class AdminNewFriendView extends AdminTemplatedView
+ {
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function AdminNewFriendView( $blogInfo, $params = Array())
+ {
+ $this->AdminTemplatedView( $blogInfo, "newfriend" );
+ }
+
+ function render()
+ {
+ // get all the friend groups
+ $friendGroups = new FriendGroups();
+ $groups = $friendGroups->getUserFriendGroups( $this->_userInfo->getId() );
+ $this->notifyEvent( EVENT_FRIEND_RELATIONSHIPS_LOADED, Array( "friendgroups" => &$groups ));
+
+ // put the data in the view
+ $this->setValue( "friendgroups", $groups );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/templates/admin/editfriend.template
===================================================================
--- plog/trunk/templates/admin/editfriend.template (rev 0)
+++ plog/trunk/templates/admin/editfriend.template 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,71 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=editFriend title=$locale->tr("editFriend")}
+
+ <form name="editFriend" action="admin.php" method="post">
+
+ <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="userAuthorizationStatusList" id="userAuthorizationStatusList">
+ {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="reset" 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/editfriends.template
===================================================================
--- plog/trunk/templates/admin/editfriends.template (rev 0)
+++ plog/trunk/templates/admin/editfriends.template 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,102 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=editFriends title=$locale->tr("editFriends")}
+
+<div id="list_nav_bar">
+<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">
+ <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}
+ <option value="{$friendGroup->getId()}" {if $currentgroup == $friendGroup->getId()} selected="selected" {/if}>{$friendGroup->getName()}</option>
+ {/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">
+ <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>
+
+ <form id="deleteFriends" action="admin.php" method="post">
+ <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="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_authorized")}</th>
+ <th style="width:110px;">{$locale->tr("friend_authorized")}</th>
+ <th style="width:95px;">{$locale->tr("actions")}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach from=$friends item=friend}
+ <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()}">{$friend->getUsername()}</a>
+ </td>
+ <td>
+ {foreach from=$friend->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=$userAuthorizedStatus key=name item=status}
+ {if $friend->getUserAuthorized() == $status}{$locale->tr($name)}{/if}
+ {/foreach}
+ </td>
+ <td>
+ {foreach from=$friendAuthorizedStatus key=name item=status}
+ {if $friend->getFriendAuthorized() == $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>
+ </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>
+ </form>
+
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
Modified: plog/trunk/templates/admin/menus.xml
===================================================================
--- plog/trunk/templates/admin/menus.xml 2007-06-12 09:30:14 UTC (rev 5530)
+++ plog/trunk/templates/admin/menus.xml 2007-06-12 11:12:44 UTC (rev 5531)
@@ -28,6 +28,8 @@
</ResourcesGroup>
<friendNetwork url="?op=friendNetwork">
<manageFriends ignoreBreadCrumbs="1">
+ <newFriend url="?op=newFriend"/>
+ <editFriends url="?op=editFriend"/>
<newFriendGroup url="?op=newFriendGroup"/>
<editFriendGroups url="?op=editFriendGroups"/>
</manageFriends>
Added: plog/trunk/templates/admin/newfriend.template
===================================================================
--- plog/trunk/templates/admin/newfriend.template (rev 0)
+++ plog/trunk/templates/admin/newfriend.template 2007-06-12 11:12:44 UTC (rev 5531)
@@ -0,0 +1,56 @@
+{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" readonly="readonly" />
+ {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="Reset" value="{$locale->tr("reset")}" />
+ <input type="submit" name="Add" value="{$locale->tr("add")}" />
+ </div>
+ </form>
+{include file="$blogtemplate/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
More information about the pLog-svn
mailing list