/**
  * Show inbox
  */
 public function inboxAction()
 {
     $current_user = Zend_Auth::getInstance()->getIdentity();
     $Messages = new Application_Model_Messages();
     $Profiles = new Application_Model_Profiles();
     $ProfilesMeta = new Application_Model_ProfilesMeta();
     $Connections = new Application_Model_Connections();
     $request = $this->getRequest();
     $user_name = $request->getParam('user', false);
     $messages = $user = $offset = false;
     if ($user_name) {
         $user = $Profiles->getProfile($user_name);
         if (!$user || $user->type != 'user') {
             $this->redirect('messages/inbox');
         }
         $users_meta = $ProfilesMeta->getMetaValues($user->id);
         // check private message privacy
         if ($current_user->role != 'admin' && $current_user->role != 'reviewer' && isset($users_meta['contact_privacy']) && $users_meta['contact_privacy'] == 'f' && !$Connections->areFriends($current_user->id, $user->id)) {
             Application_Plugin_Alerts::error($this->view->translate('Private profile (friends only)'));
             $user = false;
         }
         $messages = $Messages->getMessages($user->id);
         $Messages->markAsRead($user->id);
         // send last visible message
         $last = end($messages);
         $offset = $last['message_id'];
     }
     $this->buildMenu($user_name);
     $this->view->user = $user;
     $this->view->messages = $messages;
     $this->view->offset = $offset;
     $message_form = new Application_Form_Message();
     $this->view->message_form = $message_form;
 }
예제 #2
0
/**
 *
 * Load & submit invitation form
 *
*/
function getBetterInvitaionForm()
{
    require_once 'InviteForm.php';
    $form = new Addon_Form_BetterInvite();
    $translator = Zend_Registry::get('Zend_Translate');
    // form is submitted and valid?
    if (isset($_POST['identifier']) && $_POST['identifier'] == 'Invite') {
        if ($form->isValid($_POST)) {
            $to = $form->getValue('email');
            $subject = $translator->translate('Invitation');
            $base_url = Application_Plugin_Common::getFullBaseUrl();
            $user_id = Zend_Auth::getInstance()->getIdentity()->id;
            $user_name = Zend_Auth::getInstance()->getIdentity()->name;
            $user_screenname = Zend_Auth::getInstance()->getIdentity()->screen_name;
            $invitation_link = $base_url . '/?ref=' . $user_id;
            $profile_link = $base_url . '/' . $user_name . '/?ref=' . $user_id;
            // prepare phtml email template
            $view = new Zend_View();
            $view->setScriptPath(realpath(dirname(__FILE__)));
            $view->assign('invitation_link', $invitation_link);
            $body = $view->render('email.phtml');
            $body = str_replace("NETWORK_NAME", Zend_Registry::get('config')->get('network_name'), $body);
            $body = str_replace("INVITATION_LINK", $invitation_link, $body);
            $body = str_replace("INVITED_BY_SCREENNAME", $user_screenname, $body);
            $body = str_replace("INVITED_BY_PROFILE_LINK", $profile_link, $body);
            // send email
            $ret = Application_Plugin_Common::sendEmail($to, $subject, $body, true);
            // show info message
            if ($ret) {
                Application_Plugin_Alerts::success(Zend_Registry::get('Zend_Translate')->translate('Invitation has been sent'), 'on');
            }
        }
        // flush field
        $form->getElement('email')->setValue('');
    }
    return $form;
}
예제 #3
0
 /**
  * Follow user toggle
  */
 public function toggleFollowed($name)
 {
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         return null;
     }
     $Profiles = new Application_Model_Profiles();
     $Notifications = new Application_Model_Notifications();
     $translator = Zend_Registry::get('Zend_Translate');
     $user_id = Zend_Auth::getInstance()->getIdentity()->id;
     $follow_profile = $Profiles->getProfile($name);
     // no or bad profile
     if (!$follow_profile || !isset($follow_profile->id)) {
         return;
     }
     if ($follow_profile->type === 'page') {
         return;
     }
     $is_group = $follow_profile->type === 'group' ? true : false;
     $follow_id = $follow_profile->id;
     if ($this->isFollowing($user_id, $follow_id)) {
         if ($is_group) {
             // delete mutual connection
             $ret = $this->removeConnections($follow_id, $user_id);
             if ($ret == 2) {
                 Application_Plugin_Alerts::info(sprintf($translator->translate('You have left the group %s'), $follow_profile->screen_name));
             } else {
                 Application_Plugin_Alerts::info($translator->translate('You request has been canceled'));
             }
         } else {
             $Notifications->pushNotification(array($follow_id), 6, 'profile', $user_id);
             $this->delete(array('follow_id = ?' => (int) $follow_id, 'user_id = ?' => (int) $user_id));
             Application_Plugin_Alerts::info(sprintf($translator->translate('You have stopped following %s'), $follow_profile->screen_name));
         }
         return;
     } else {
         if ($is_group) {
             $data = array('user_id' => $user_id, 'follow_id' => $follow_id, 'created_on' => Application_Plugin_Common::now());
             $ret = $this->insert($data);
             if ($follow_profile->profile_privacy === 'friends' && $follow_profile->owner != $user_id) {
                 // admin will have to confirm this
                 Application_Plugin_Alerts::success(sprintf($translator->translate('Your request to join this group has been sent to %s'), $follow_profile->screen_name));
                 // notify group admin that new user has requested membership
                 $Notifications->pushNotification(array($follow_profile->owner), 12, 'profile', $follow_id);
             } else {
                 // join the group by adding mutual follow
                 $data = array('user_id' => $follow_id, 'follow_id' => $user_id, 'created_on' => Application_Plugin_Common::now());
                 $this->insert($data);
                 Application_Plugin_Alerts::success(sprintf($translator->translate('You have joined the group %s'), $follow_profile->screen_name));
             }
         } else {
             $data = array('user_id' => $user_id, 'follow_id' => $follow_id, 'created_on' => Application_Plugin_Common::now());
             $this->insert($data);
             if ($this->areFriends($user_id, $follow_id)) {
                 // follow, areFriends
                 // are friends now, notify user
                 $Notifications->pushNotification(array($follow_id), 4, 'profile', $user_id);
                 if ($is_group) {
                     Application_Plugin_Alerts::success(sprintf($translator->translate('You have joined the group %s'), $follow_profile->screen_name));
                 } else {
                     Application_Plugin_Alerts::success(sprintf($translator->translate('You are now friends with %s'), $follow_profile->screen_name));
                 }
                 return;
             }
             // new follower, notify user
             $Notifications->pushNotification(array($follow_id), 3, 'profile', $user_id);
             Application_Plugin_Alerts::success(sprintf($translator->translate('You are now following %s'), $follow_profile->screen_name));
         }
         // follow
         return;
     }
     return false;
 }
예제 #4
0
/**
 * Register with facebook
 */
function registerWithFacebook()
{
    // flush if already logged in
    Zend_Auth::getInstance()->clearIdentity();
    $session = new Zend_Session_Namespace('Default');
    $email = $session->fb_user_email;
    $avatar = $session->fb_avatar;
    // do not allow direct access - without fb_user_email inside session
    if (!$session->fb_user_email) {
        Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector')->gotoUrl('');
    }
    require_once 'Form.php';
    $registerwithfacebook_form = new Addon_FacebookRegisterForm();
    $Profiles = new Application_Model_Profiles();
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if ($registerwithfacebook_form->isValid($_POST)) {
            $name = $registerwithfacebook_form->getValue('name');
            $user = $Profiles->createRow();
            $user->name = $name;
            $user->email = $email;
            $user->password = '';
            $user->activationkey = 'activated';
            $user->language = Zend_Registry::get('config')->get('default_language');
            $user = $Profiles->createNewUser($user, 'facebook');
            // update last login date
            $ProfilesMeta = new Application_Model_ProfilesMeta();
            $ProfilesMeta->metaUpdate('last_login', Application_Plugin_Common::now(), $user->id);
            $Storage = new Application_Model_Storage();
            $StorageAdapter = $Storage->getAdapter();
            $defaultres = 64;
            $bigres = Zend_Registry::get('config')->get('avatar_size') ? Zend_Registry::get('config')->get('avatar_size') : $defaultres;
            // get the image
            $c = new Zend_Http_Client();
            $c->setUri($avatar);
            $result = $c->request('GET');
            $img = imagecreatefromstring($result->getBody());
            // create regular avatar image, resample and store
            $imgname = 'profileimage_' . $name . '.jpg';
            imagejpeg($img, TMP_PATH . '/' . $imgname);
            Application_Plugin_ImageLib::resample(TMP_PATH . '/' . $imgname, TMP_PATH . '/' . $imgname, $defaultres, $defaultres, false);
            $new_filename = $StorageAdapter->moveFileToStorage($imgname, 'avatar');
            $Profiles->updateField($name, 'avatar', $new_filename);
            // create big avatar image, resample and store
            $imgname = 'bigprofileimage_' . $name . '.jpg';
            imagejpeg($img, TMP_PATH . '/' . $imgname);
            Application_Plugin_ImageLib::resample(TMP_PATH . '/' . $imgname, TMP_PATH . '/' . $imgname, $bigres, $bigres, false);
            $big_avatar = $StorageAdapter->moveFileToStorage($imgname, 'avatar');
            $ProfilesMeta->metaUpdate('big_avatar', $big_avatar, $user->id);
            // free img resource
            imagedestroy($img);
            // login user
            $emailAuthAdapter = Application_Plugin_Common::getEmailAuthAdapter($email);
            $auth = Zend_Auth::getInstance();
            $auth->authenticate($emailAuthAdapter);
            $identity = $emailAuthAdapter->getResultRowObject();
            $authStorage = $auth->getStorage();
            $authStorage->write($identity);
            // clear session data
            $session->fb_user_email = '';
            $session->fb_user_display_name = '';
            $session->fb_avatar = '';
            $user_id = $user->id;
            // trigger hooks
            Zend_Registry::get('hooks')->trigger('hook_firsttimelogin', $user_id);
            // show welcome message
            Application_Plugin_Alerts::success(Zend_Registry::get('Zend_Translate')->translate('Welcome to the network.'), 'on');
            Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector')->gotoUrl('');
        }
    }
    echo $registerwithfacebook_form;
}
예제 #5
0
 /**
  * Lost password
  */
 public function submitLostPasswordForm($form)
 {
     $front = Zend_Controller_Front::getInstance();
     if ($form->isValid($_POST)) {
         $name = $form->getValue('name');
         $Profiles = new Application_Model_Profiles();
         $nameRow = $Profiles->getProfileByField('name', $name);
         // maybe user is entering email?
         $nameRow_byEmail = $Profiles->getProfileByField('email', $name);
         if ($nameRow_byEmail) {
             $nameRow = $Profiles->getProfileByField('name', $nameRow_byEmail->name);
         }
         if ($nameRow && $Profiles->isActivated($nameRow->name) && $nameRow->is_hidden == 0) {
             $resetPasswordKey = $Profiles->generateActivationKey($nameRow->email);
             $ProfilesMeta = new Application_Model_ProfilesMeta();
             $profile = $ProfilesMeta->metaUpdate('password_reset', $resetPasswordKey, $nameRow->id);
             // password recovery email
             $ret = Application_Plugin_Common::sendRecoveryEmail($nameRow->email, $name, $resetPasswordKey);
             // show info message
             if ($ret) {
                 Application_Plugin_Alerts::success(Zend_Registry::get('Zend_Translate')->translate('We have sent an email to your registered email address. Follow the instructions and you will be able to enter a new password.'), 'off');
             }
             // flush url
             Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector')->gotoUrl('');
         } else {
             sleep(2);
             $form->getElement('name')->setErrors(array(Zend_Registry::get('Zend_Translate')->translate('Username does not exists')));
         }
     }
     return $form;
 }
 /**
  */
 public function setImage()
 {
     // Form Submitted...
     if ($this->request->isPost() && $this->form->isValid($_POST)) {
         // file uploaded?
         if ($this->form->{$this->file_element}->isUploaded()) {
             $this->form->{$this->file_element}->receive();
             // must have
             $receive_path = $this->form->{$this->file_element}->getFileName();
             $filename = $this->form->{$this->file_element}->getValue();
             $extension = strtolower(pathinfo($receive_path, PATHINFO_EXTENSION));
             if ($this->profile_name) {
                 // delete old tmp image files
                 $Storage = new Application_Model_Storage();
                 $StorageAdapter = $Storage->getAdapter();
                 $StorageAdapter->deleteOldTmpFiles(0, 'profileimage_' . $this->profile_name);
                 $tmp_filename = 'profileimage_' . $this->profile_name . '.' . $extension;
                 // move new file to tmp folder
                 rename($receive_path, TMP_PATH . '/' . $tmp_filename);
                 // check if valid image
                 if (!Application_Plugin_ImageLib::isValidImage(TMP_PATH . '/' . $tmp_filename)) {
                     unlink(TMP_PATH . '/' . $tmp_filename);
                     Application_Plugin_Alerts::error($this->translator->translate('Server-side error'), 'off');
                     $this->redirector->gotoUrl();
                     return;
                 }
                 Application_Plugin_Alerts::success($this->translator->translate('You can adjust the picture here'), 'off');
                 // go back to current page after editing
                 $base_url = Application_Plugin_Common::getFullBaseUrl(false);
                 $callback_url = $base_url . $this->request->getRequestUri() . '/edit_done/1';
                 // save params to session and redirect to edit page
                 $session = new Zend_Session_Namespace('Default');
                 $pass_params = array('tmp_image' => $tmp_filename, 'image_type' => $this->image_type, 'callback' => $callback_url, 'profile_name' => $this->profile_name);
                 $session->pass_params = $pass_params;
                 $this->redirector->gotoUrl('images/edit');
             } else {
                 // here we store site settings images
                 // i.e. network background image
                 $this->form->{$this->file_element}->receive();
                 // must have
                 $receive_path = $this->form->{$this->file_element}->getFileName();
                 $filename = $this->form->{$this->file_element}->getValue();
                 $extension = strtolower(pathinfo($receive_path, PATHINFO_EXTENSION));
                 $file_name = $this->image_type . '.' . $extension;
                 // move new file to public image folder
                 rename($receive_path, PUBLIC_PATH . '/images/' . $file_name);
                 // store to app settings & refresh
                 $app_option_key = $this->image_type;
                 $AppOptions = new Application_Model_AppOptions();
                 $AppOptions->updateOption($app_option_key, $file_name);
                 $current_config = Zend_Registry::get('config');
                 $current_config->{$app_option_key} = $file_name;
                 Zend_Registry::set('config', $current_config);
                 Application_Plugin_Alerts::success($this->translator->translate('Image uploaded'), 'off');
                 $base_url = Application_Plugin_Common::getFullBaseUrl(false);
                 $callback_url = $base_url . $this->request->getRequestUri();
                 // flush url
                 $this->redirector->gotoUrl($callback_url);
             }
         } else {
             if ($this->is_requiered) {
                 // nothing to upload
                 Application_Plugin_Alerts::error($this->translator->translate('Please choose a picture'), 'off');
             }
         }
     }
     // somethig went wrong, image too big?
     if ($this->request->isPost() && !$this->form->isValid($_POST)) {
         Application_Plugin_Alerts::error($this->translator->translate('File not allowed or too big'), 'off');
     }
 }
 /**
  * Theme & style
  */
 public function stylesAction()
 {
     $this->buildSettingsMenu();
     $request = $this->getRequest();
     $form = new Application_Form_SettingsStyle();
     $this->view->form = $form;
     if ($request->isPost() && $form->isValid($_POST)) {
         $AppOptions = new Application_Model_AppOptions();
         $AppOptions->updateOption('css_theme', $form->getValue('css_theme'));
         $AppOptions->updateOption('css_custom', $form->getValue('css_custom'));
         $AppOptions->updateOption('cover_ysize', $form->getValue('cover_ysize'));
         $AppOptions->updateOption('user_background', $form->getValue('user_background'));
         $AppOptions->updateOption('subscriber_background', $form->getValue('subscriber_background'));
         $AppOptions->updateOption('wide_layout', $form->getValue('wide_layout'));
         Application_Plugin_Alerts::success($this->view->translate('Settings updated, please clear your browser cache'), 'off');
         // flush url
         $this->redirect('admin/styles/section/styles/');
     }
 }
 /**
  * Edit image
  */
 public function editAction()
 {
     $request = $this->getRequest();
     $do_rotate = $request->getParam('rotate');
     $do_skip = $request->getParam('skip');
     $Profiles = new Application_Model_Profiles();
     $profile = $Profiles->getProfileRow($this->profile_name, true, true);
     if (!$profile) {
         $this->redirect('');
     }
     $extension = strtolower(pathinfo(TMP_PATH . '/' . $this->image_name, PATHINFO_EXTENSION));
     if ($request->isPost() || $do_skip) {
         if ($do_skip) {
             // skip editing and use the full image
             Application_Plugin_ImageLib::resample(TMP_PATH . '/' . $this->image_name, TMP_PATH . '/' . $this->image_name, $this->target_x, $this->target_y, false);
         } else {
             $x = intval($_POST['x']);
             $y = intval($_POST['y']);
             $w = intval($_POST['w']);
             $h = intval($_POST['h']);
             if ($x + $y + $w + $h == 0) {
                 $this->redirect('');
             }
             Application_Plugin_ImageLib::crop(TMP_PATH . '/' . $this->image_name, $x, $y, $w, $h, $this->target_x, $this->target_y);
         }
         $Storage = new Application_Model_Storage();
         $StorageAdapter = $Storage->getAdapter();
         // delete old file
         if (strstr($profile->{$this->db_field}, 'default') === false) {
             $StorageAdapter->deleteFileFromStorage($profile->{$this->db_field}, $this->image_type);
         }
         $new_filename = $StorageAdapter->moveFileToStorage($this->view->image, $this->image_type);
         $profile->{$this->db_field} = $new_filename;
         $profile->save();
         Application_Plugin_Alerts::success($this->view->translate('Image saved'));
         // kill tmp session
         $session = new Zend_Session_Namespace('Default');
         $session->pass_params = false;
         // refresh user session in case profile picture is updated
         Zend_Auth::getInstance()->getStorage()->write($Profiles->getProfileRowObject());
         // go back
         $this->redirect($this->callback);
     } elseif ($do_rotate) {
         Application_Plugin_ImageLib::rotate(TMP_PATH . '/' . $this->image_name);
     }
 }
 /**
  * Fetch and prepare profiles for view
  */
 public function prepareProfiles($type, $filters = false)
 {
     $Profiles = new Application_Model_Profiles();
     $count = $Profiles->searchProfiles($this->search_term, $filters, $type, true);
     $this->view->pagination_last_page = (int) ceil($count / (int) Zend_Registry::get('config')->get('pagination_limit'));
     $this->view->pagination_current_page = $this->page;
     $Profiles->page_number = $this->page;
     if ($count > 0) {
         $this->view->profiles = $Profiles->searchProfiles($this->search_term, $filters, $type);
     } else {
         Application_Plugin_Alerts::info($this->view->translate('Nothing found...'), 'off');
     }
     // set single view script
     $this->render('profiles');
 }
예제 #10
0
 /**
  * Activation link lands here to activate user account
  */
 public function activateAction()
 {
     $this->_helper->_layout->setLayout('layout_wide');
     // flush if already logged in
     Zend_Auth::getInstance()->clearIdentity();
     $activateaccount_form = new Application_Form_ActivateAccount();
     $this->view->activateaccount_form = $activateaccount_form;
     $key = $this->getRequest()->getParam('key', false);
     $resend_username = $this->getRequest()->getParam('resend', false);
     $Profiles = new Application_Model_Profiles();
     $ProfilesMeta = new Application_Model_ProfilesMeta();
     $userData = $Profiles->getProfileByField('activationkey', $key);
     if (!$userData || $key == 'activated') {
         // try if this is a resend
         $userData = $Profiles->getProfile($resend_username);
         if (!$userData || $userData->activationkey == 'activated') {
             $this->redirect('');
         } else {
             $resend_lock = $ProfilesMeta->getMetaValue('resend_activation_lock', $userData->id);
             $hour_lock = date('H');
             // prevent too many attempts
             if ($resend_lock && $resend_lock == $hour_lock) {
                 Application_Plugin_Alerts::info(Zend_Registry::get('Zend_Translate')->translate('Please Check your Inbox and come back after you activate your account.'), 'off');
                 $this->redirect('');
             }
             $ret = Application_Plugin_Common::sendActivationEmail($userData->email, $userData->name, $userData->activationkey);
             // email has been sent, show success message
             if ($ret) {
                 Application_Plugin_Alerts::info(Zend_Registry::get('Zend_Translate')->translate('Please Check your Inbox and come back after you activate your account.'), 'off');
                 // once per day
                 $ProfilesMeta->metaUpdate('resend_activation_lock', $hour_lock, $userData->id);
             } else {
                 // show error message
                 Application_Plugin_Alerts::error(Zend_Registry::get('Zend_Translate')->translate('Something went wrong, email was not sent.'), 'off');
             }
             $this->redirect('');
         }
     }
     $request = $this->getRequest();
     if ($request->isPost() && isset($_POST['identifier']) && $_POST['identifier'] == 'ActivateAccount') {
         if ($activateaccount_form->isValid($_POST)) {
             if ($Profiles->activateAccount($key)) {
                 // auto-login user and store identity
                 $authAdapter = Application_Plugin_Common::getAuthAdapter();
                 $authAdapter->setIdentity($userData->email)->setCredential('whatever')->setCredentialTreatment('autologin');
                 $auth = Zend_Auth::getInstance();
                 $auth->authenticate($authAdapter);
                 $identity = $authAdapter->getResultRowObject();
                 $authStorage = $auth->getStorage();
                 $authStorage->write($identity);
                 // update last login date
                 $ProfilesMeta = new Application_Model_ProfilesMeta();
                 $ProfilesMeta->metaUpdate('last_login', Application_Plugin_Common::now(), $identity->id);
                 // show welcome message
                 Application_Plugin_Alerts::success($this->view->translate('Welcome to the network.'), 'on');
                 $this->redirect('');
             }
         }
     }
 }
예제 #11
0
 public function GetAlerts()
 {
     return Application_Plugin_Alerts::getMessages();
 }
예제 #12
0
 /**
  * Get user/group data
  */
 public function getProfile($name = null, $get_hidden = false, $check_ownership = false)
 {
     if ($name == null && Zend_Auth::getInstance()->hasIdentity()) {
         $name = Zend_Auth::getInstance()->getIdentity()->name;
     }
     $name = $this->getDefaultAdapter()->quote($name);
     $sql = "\r\n\t\tSELECT\r\n\t\t*\r\n\t\tFROM profiles p\r\n\t\tWHERE name = {$name}\r\n\t\t";
     // show hidden users for admin
     if (Zend_Auth::getInstance()->hasIdentity() && Zend_Auth::getInstance()->getIdentity()->role === 'admin') {
         $get_hidden = true;
     }
     if (!$get_hidden) {
         $sql .= " AND is_hidden = 0 ";
     }
     $result = $this->getDefaultAdapter()->fetchRow($sql, array(), Zend_Db::FETCH_OBJ);
     // profile does not exitst
     if (!$result) {
         return false;
     }
     // check ownership
     if ($check_ownership && !Zend_Auth::getInstance()->hasIdentity() || $check_ownership && Zend_Auth::getInstance()->getIdentity()->id != $result->owner && $check_ownership && Zend_Auth::getInstance()->getIdentity()->id != $result->id && $check_ownership && Zend_Auth::getInstance()->getIdentity()->role !== 'admin') {
         $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
         Application_Plugin_Alerts::error(Zend_Registry::get('Zend_Translate')->translate('Error - not permitted'), 'off');
         $redirector->gotoSimple('index', 'index');
         return false;
     }
     if ($result->type === 'page') {
         $Likes = new Application_Model_Likes();
         $result->is_liked = $Likes->isLiked($result->id, 'page');
         $result->likes_count = $Likes->getLikesCount($result->id, 'page');
     }
     return $result;
 }
 /**
  * Edit comment
  */
 public function editcommentAction()
 {
     $Reports = new Application_Model_Reports();
     $total_counts = $Reports->getTotalCount();
     $this->buildMenu($total_counts);
     $request = $this->getRequest();
     $page = (int) $request->getParam('page');
     $comment_id = (int) $request->getParam('comment');
     $Comments = new Application_Model_Comments();
     $comment = $Comments->getComment($comment_id);
     // load and fill up form
     $edit_comment_form = new Application_Form_EditComment();
     $edit_comment_form->getElement('comment')->setValue($comment['content']);
     $this->view->edit_comment_form = $edit_comment_form;
     if ($request->isPost() && $edit_comment_form->isValid($_POST)) {
         $comment_content = $edit_comment_form->getElement('comment')->getValue();
         $comment_content = Application_Plugin_Common::prepareComment($comment_content);
         // drop on false
         if ($comment_content === false) {
             return;
         }
         $Comments->updateComment($comment_id, $comment_content);
         Application_Plugin_Alerts::success($this->view->translate('Comment updated'));
         if ($page > 0) {
             $this->redirect('reports/reviewcomments/page/' . $page);
         }
     }
 }
예제 #14
0
 /**
  * Disable editing of demo accounts
  */
 public static function redirectOnDemoAccount()
 {
     $demo_account_name = 'user1';
     if (Zend_Auth::getInstance()->hasIdentity() && Zend_Auth::getInstance()->getIdentity()->name == $demo_account_name) {
         Application_Plugin_Alerts::error(Zend_Registry::get('Zend_Translate')->translate('Cannot edit demo user'));
         $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
         $redirector->gotoUrl('');
     }
 }
 /**
  * Create a page
  */
 public function createpageAction()
 {
     $this->buildMenu(true);
     $request = $this->getRequest();
     $Profiles = new Application_Model_Profiles();
     $profile_form = new Application_Form_AddPage();
     $this->view->profile_form = $profile_form;
     if ($request->isPost() && $profile_form->isValid($_POST)) {
         if ($Profiles->getProfile($profile_form->getValue('name'), true)) {
             $profile_form->getElement('name')->setErrors(array(Zend_Registry::get('Zend_Translate')->translate('This username is not available')));
             return;
         }
         $profile = $Profiles->createRow();
         $profile->owner = Zend_Auth::getInstance()->getIdentity()->id;
         $profile->name = $profile_form->getValue('name');
         $profile->screen_name = $profile_form->getValue('screen_name');
         $profile->profile_privacy = 'public';
         $Profiles->createNewPage($profile);
         $ProfilesMeta = new Application_Model_ProfilesMeta();
         $ProfilesMeta->metaUpdate('description', $profile_form->getValue('description'), $profile->id);
         Application_Plugin_Alerts::success($this->view->translate('New page created'));
         $this->redirect('editprofile/listpages');
     }
 }
 /**
  * Create an album
  */
 public function createalbumAction()
 {
     $request = $this->getRequest();
     $Albums = new Application_Model_Albums();
     $album_form = new Application_Form_AddAlbum();
     $this->view->album_form = $album_form;
     $this->prepareProfile($this->profile);
     $this->prepareImagesAlbumsCount();
     if ($request->isPost() && $album_form->isValid($_POST)) {
         $album_name = $album_form->getValue('album_name');
         $description = $album_form->getValue('description');
         $Albums->createAlbum($album_name, $description);
         Application_Plugin_Alerts::success($this->view->translate('New album created'));
         $this->redirect('profiles/albums');
     }
 }