Esempio n. 1
2
 public function indexAction()
 {
     $this->view->form = $form = new Ynnotification_Form_Admin_Style();
     $values = Engine_Api::_()->getApi('settings', 'core')->getSetting('avdnotification.customcssobj', 0);
     $values = Zend_JSON::decode($values);
     if ($values) {
         $form->populate($values);
     }
     if ($this->getRequest()->isPost() && $form->isValid($this->_getAllParams())) {
         $values = $form->getValues();
         if (isset($_POST['submit'])) {
             // $str = $this->view->partial("_css.tpl");
             $arr_keys = array_keys($values);
             $arr_values = array_values($values);
             $arr_keys = array_map(array($this, 'map'), $arr_keys);
             $str = str_replace($arr_keys, $arr_values, $str);
             Engine_Api::_()->getApi('settings', 'core')->setSetting('avdnotification.customcssobj', Zend_JSON::encode($values));
             Engine_Api::_()->getApi('settings', 'core')->setSetting('avdnotification', $str);
             $form->addNotice('Your changes have been saved.');
         } else {
             if (isset($_POST['clear'])) {
                 Engine_Api::_()->getApi('settings', 'core')->setSetting('avdnotification.customcssobj', '');
                 Engine_Api::_()->getApi('settings', 'core')->setSetting('avdnotification', '');
                 $form->populate(array('mes_background' => '79B4D4', 'text_color' => ''));
                 $form->addNotice('You have set default styles.');
             }
         }
     }
 }
Esempio n. 2
1
 public function init()
 {
     $view = Zend_Registry::get('Zend_View');
     $this->setTitle('Delete Sub Library');
     $this->setAttrib('class', 'global_form_popup');
     $this->setDescription('Are you sure that you want to delete this library? It will not be recoverable after being deleted.');
     //get table
     $mappingTable = Engine_Api::_()->getDbTable('mappings', 'user');
     //get videos mapping of library
     $params = array();
     $params['owner_type'] = $this->_library->getType();
     $params['owner_id'] = $this->_library->getIdentity();
     $videoMappings = $mappingTable->getItemsMapping('video', $params);
     if (count($this->_subs) && count($videoMappings)) {
         //get main Library
         $viewer = Engine_Api::_()->user()->getViewer();
         $mainLibrary = $viewer->getMainLibrary();
         $arrValue = array();
         $arrValue[0] = $view->translate('None');
         $arrValue[$mainLibrary->getIdentity()] = $view->translate($mainLibrary->getTitle());
         foreach ($this->_subs as $sub) {
             if ($sub->isSelf($this->_library)) {
                 continue;
             }
             $arrValue[$sub->getIdentity()] = $view->translate($sub->getTitle());
         }
         $this->addElement('Select', 'move_to', array('label' => 'Move to Library?', 'description' => 'If you delete this library, all existing content will be moved to another one.', 'multiOptions' => $arrValue));
     }
     $this->addElement('Button', 'submit_button', array('value' => 'submit_button', 'label' => 'Delete', 'onclick' => 'removeSubmit()', 'type' => 'submit', 'ignore' => true, 'decorators' => array('ViewHelper')));
     $this->addElement('Cancel', 'cancel', array('label' => 'cancel', 'link' => true, 'prependText' => ' or ', 'href' => '', 'onclick' => 'parent.Smoothbox.close();', 'decorators' => array('ViewHelper')));
     $this->addDisplayGroup(array('submit_button', 'cancel'), 'buttons', array('decorators' => array('FormElements', 'DivDivDivWrapper')));
 }
Esempio n. 3
0
 public function init()
 {
     $this->clearDecorators()->addDecorator('FormElements')->addDecorator('Form')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'search'))->addDecorator('HtmlTag2', array('tag' => 'div', 'class' => 'clear'));
     $this->setAttribs(array('id' => 'filter_form', 'class' => 'global_form_box'))->setMethod('GET');
     $types = Engine_Api::_()->getDbtable('modules', 'ynmoderation')->getTypesAssoc();
     $typeMultiOptions = array(0 => ' ');
     foreach ($types as $key => $value) {
         $typeMultiOptions[$key] = $value;
     }
     $type_id = new Zend_Form_Element_Select('type_id');
     $type_id->setLabel('Type')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'))->setMultiOptions($typeMultiOptions);
     $description = new Zend_Form_Element_Text('description');
     $description->setLabel('Description')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'));
     $submit = new Zend_Form_Element_Button('search', array('type' => 'submit'));
     $submit->setLabel('Search')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'buttons'))->addDecorator('HtmlTag2', array('tag' => 'div'));
     $this->addElement('Hidden', 'order', array('order' => 10001));
     $this->addElement('Hidden', 'order_direction', array('order' => 10002));
     $this->addElements(array($type_id, $description, $submit));
     // Set default action without URL-specified params
     $params = array();
     foreach (array_keys($this->getValues()) as $key) {
         $params[$key] = null;
     }
     $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble($params));
 }
 protected function _initLog()
 {
     $log = new Zend_Log();
     // Non-production
     if (APPLICATION_ENV !== 'production') {
         $log->addWriter(new Zend_Log_Writer_Firebug());
     }
     // Production
     try {
         $log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/install.log'));
     } catch (Exception $e) {
         // Check directory
         if (!@is_dir(APPLICATION_PATH . '/temporary/log') && @mkdir(APPLICATION_PATH . '/temporary/log', 0777, true)) {
             $log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/install.log'));
         } else {
             // Silence ...
             if (APPLICATION_ENV !== 'production') {
                 $log->log($e->__toString(), Zend_Log::CRIT);
             } else {
                 // Make sure logging doesn't cause exceptions
                 $log->addWriter(new Zend_Log_Writer_Null());
             }
         }
     }
     Zend_Registry::set('Zend_Log', $log);
     Engine_Api::registerErrorHandlers();
     if ('production' != APPLICATION_ENV) {
         Engine_Exception::setLog($log);
     }
     return $log;
 }
Esempio n. 5
0
 public function onUserLoginAfter($event)
 {
     // Arg should be an instance of Zend_View
     $user = $event->getPayload();
     if (!isset($user->email)) {
         return;
     }
     if (!$user instanceof User_Model_User || empty($user->email)) {
         return;
     }
     $settings = Engine_Api::_()->getApi('settings', 'core');
     if (!$settings->getSetting('ynfeedback_guest_merge', 1)) {
         return;
     }
     $email = $user->email;
     $ideaTable = Engine_Api::_()->getItemTable('ynfeedback_idea');
     $data = array('user_id' => $user->getIdentity());
     $where = $ideaTable->getAdapter()->quoteInto('guest_email = ?', $email);
     $idea = $ideaTable->update($data, $where);
     $commentTable = Engine_Api::_()->getDbTable('comments', 'ynfeedback');
     $data = array('poster_id' => $user->getIdentity());
     $where = $commentTable->getAdapter()->quoteInto('poster_email = ?', $email);
     $comment = $commentTable->update($data, $where);
     //send notification
     if ($idea || $comment) {
         $notifyApi = Engine_Api::_()->getDbtable('notifications', 'activity');
         $notifyApi->addNotification($user, $user, $user, 'ynfeedback_idea_signupmerge', array('params' => array('route' => 'ynfeedback_general', 'action' => 'manage'), 'innerHTML' => ''));
     }
 }
Esempio n. 6
0
 public function ynfeed(Activity_Model_Action $action = null, array $data = array(), $method = null, $show_all_comments = false)
 {
     if (null === $action) {
         return '';
     }
     $activity_moderate = "";
     $viewer = Engine_Api::_()->user()->getViewer();
     if ($viewer->getIdentity()) {
         $activity_moderate = Engine_Api::_()->getDbtable('permissions', 'authorization')->getAllowed('user', $viewer->level_id, 'activity');
     }
     $form = new Activity_Form_Comment();
     $data = array_merge($data, array('actions' => array($action), 'commentForm' => $form, 'user_limit' => Engine_Api::_()->getApi('settings', 'core')->getSetting('activity_userlength'), 'allow_delete' => Engine_Api::_()->getApi('settings', 'core')->getSetting('activity_userdelete'), 'activity_moderate' => $activity_moderate, 'viewAllComments' => isset($data['viewAllComments']) && $data['viewAllComments'] ? $data['viewAllComments'] : $show_all_comments, 'allowSaveFeed' => Engine_Api::_()->getApi('settings', 'core')->getSetting('ynfeed_savefeed', true), 'onlyactivity' => 1));
     if (Engine_Api::_()->ynfeed()->checkEnabledAdvancedComment()) {
         $data = array_merge($data, array('replyForm' => new Yncomment_Form_Reply()));
         if ($method == 'update') {
             if (!Engine_Api::_()->getApi('settings', 'core')->getSetting('activity.commentreverseorder', false)) {
                 return $this->view->partial('_yncomment_activityComments.tpl', 'yncomment', $data);
             } else {
                 return $this->view->partial('_yncomment_activityComments_reverse_chronological.tpl', 'yncomment', $data);
             }
         } else {
             if (!Engine_Api::_()->getApi('settings', 'core')->getSetting('activity.commentreverseorder', false)) {
                 return $this->view->partial('_yncomment_activityText.tpl', 'yncomment', $data);
             } else {
                 return $this->view->partial('_yncomment_activityText_reverse_chronological.tpl', 'yncomment', $data);
             }
         }
     } else {
         if ($method == 'update') {
             return $this->view->partial('_activityComments.tpl', 'activity', $data);
         } else {
             return $this->view->partial('_activityText.tpl', 'ynfeed', $data);
         }
     }
 }
 public function init()
 {
     $description = $this->getTranslator()->translate('Conrols settings about access to the admin panel. <br>');
     $settings = Engine_Api::_()->getApi('settings', 'core');
     if ($settings->getSetting('user.support.links', 0) == 1) {
         $moreinfo = $this->getTranslator()->translate('More Info: <a href="%1$s" target="_blank"> KB Article</a>');
     } else {
         $moreinfo = $this->getTranslator()->translate('');
     }
     $description = vsprintf($description . $moreinfo, array('http://support.socialengine.com/questions/170/Admin-Panel-Settings-Admin-Password'));
     // Decorators
     $this->loadDefaultDecorators();
     $this->getDecorator('Description')->setOption('escape', false);
     $this->setTitle('Admin Reauthentication')->setDescription($description);
     // Mode
     $this->addElement('Radio', 'mode', array('multiOptions' => array('none' => 'Do not require reauthentication.', 'user' => 'Require admins to re-enter their password when they try to access the admin panel.', 'global' => 'Require admins to enter a global password when they try to access the admin panel.')));
     // Password
     $this->addElement('Password', 'password', array('label' => 'Password', 'description' => 'The password for "Require admins to enter a global password when they try to access the admin panel." above (otherwise ignore).'));
     // Password confirm
     $this->addElement('Password', 'password_confirm', array('label' => 'Password Again', 'description' => 'Confirm password'));
     // timeout
     $this->addElement('Text', 'timeout', array('label' => 'Timeout', 'description' => 'How long (in seconds) before admins have to reauthenticate?', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Int', true), array('Between', true, array(300, 86400)))));
     // init submit
     $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
 }
Esempio n. 8
0
 public function init()
 {
     $arrPhotoIds = array();
     foreach ($this->_data as $data) {
         if (!empty($data['photo_id'])) {
             $arrPhotoIds[$data['user_id']] = $data['photo_id'];
         }
     }
     $fileTbl = Engine_Api::_()->getItemTable('storage_file');
     $files = $fileTbl->getMultiFiles($arrPhotoIds);
     if (!empty($files)) {
         $urls = array();
         foreach ($files as $file) {
             if (!array_key_exists($file->getIdentity(), $urls)) {
                 $url = array();
             } else {
                 $url = $urls[$file->parent_file_id];
             }
             $url = $file->map();
             if (empty($urls[$file->parent_file_id])) {
                 $urls[$file->parent_file_id] = array();
             }
             $urls[$file->parent_file_id][$file->type] = $url;
         }
         foreach ($this->_data as $index => $data) {
             if (!empty($data['photo_id']) && isset($urls[$data['photo_id']])) {
                 $this->_data[$index]['photo_url'] = $urls[$data['photo_id']];
             }
         }
     }
 }
 public function checkRequire()
 {
     try {
         $subject = Engine_Api::_()->core()->getSubject();
     } catch (Exception $e) {
         $subject = null;
     }
     $actionName = $this->getFrontController()->getRequest()->getActionName();
     $ret = true;
     if (!$subject instanceof Core_Model_Item_Abstract || !$subject->getIdentity()) {
         $ret = false;
     } else {
         if (null !== $this->_requiredType && $subject->getType() != $this->_requiredType) {
             $ret = false;
         } else {
             if (null !== ($requireType = $this->getActionRequireType($actionName)) && $subject->getType() != $requireType) {
                 $ret = false;
             }
         }
     }
     if (!$ret && APPLICATION_ENV == 'development' && Zend_Registry::isRegistered('Zend_Log') && ($log = Zend_Registry::get('Zend_Log')) instanceof Zend_Log) {
         $target = $this->getRequest()->getModuleName() . '.' . $this->getRequest()->getControllerName() . '.' . $this->getRequest()->getActionName();
         $log->log('Require class ' . get_class($this) . ' failed check for: ' . $target, Zend_Log::DEBUG);
     }
     return $ret;
 }
Esempio n. 10
0
 public function indexAction()
 {
     // Should we consider creation or modified recent?
     $recentType = $this->_getParam('recentType', 'creation');
     if (!in_array($recentType, array('creation', 'modified'))) {
         $recentType = 'creation';
     }
     $this->view->recentType = $recentType;
     $this->view->recentCol = $recentCol = $recentType . '_date';
     // Get paginator
     $table = Engine_Api::_()->getItemTable('video');
     $select = $table->select()->where('search = ?', 1)->where('status = ?', 1);
     if ($recentType == 'creation') {
         // using primary should be much faster, so use that for creation
         $select->order('video_id DESC');
     } else {
         $select->order($recentCol . ' DESC');
     }
     $this->view->paginator = $paginator = Zend_Paginator::factory($select);
     // Set item count per page and current page number
     $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 4));
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     // Hide if nothing to show
     if ($paginator->getTotalItemCount() <= 0) {
         return $this->setNoRender();
     }
 }
Esempio n. 11
0
 public function indexAction()
 {
     $table = Engine_Api::_()->getItemTable('ynfeedback_idea');
     $select = $table->getIdeasSelect(array('orderby' => 'vote_count', 'direction' => 'DESC'));
     $select->limit(Engine_Api::_()->getApi('settings', 'core')->getSetting('ynfeedback_max_idea', 20));
     $this->view->ideas = $table->fetchAll($select);
 }
Esempio n. 12
0
 public function onMenuInitialize_UserProfileMessage($row)
 {
     // Not logged in
     $viewer = Engine_Api::_()->user()->getViewer();
     $subject = Engine_Api::_()->core()->getSubject();
     if (!$viewer->getIdentity() || $viewer->getGuid(false) === $subject->getGuid(false)) {
         return false;
     }
     // Get setting?
     $permission = Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'messages', 'create');
     if (Authorization_Api_Core::LEVEL_DISALLOW === $permission) {
         return false;
     }
     $messageAuth = Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'messages', 'auth');
     if ($messageAuth == 'none') {
         return false;
     } else {
         if ($messageAuth == 'friends') {
             // Get data
             $direction = (int) Engine_Api::_()->getApi('settings', 'core')->getSetting('user.friends.direction', 1);
             if (!$direction) {
                 //one way
                 $friendship_status = $viewer->membership()->getRow($subject);
             } else {
                 $friendship_status = $subject->membership()->getRow($viewer);
             }
             if (!$friendship_status || $friendship_status->active == 0) {
                 return false;
             }
         }
     }
     return array('label' => "Send Message", 'icon' => 'application/modules/Messages/externals/images/send.png', 'route' => 'messages_general', 'params' => array('action' => 'compose', 'to' => $subject->getIdentity()));
 }
Esempio n. 13
0
 public function editAction()
 {
     // In smoothbox
     $this->_helper->layout->setLayout('admin-simple');
     // Must have an id
     if (!($id = $this->_getParam('id'))) {
         die('No identifier specified');
     }
     $typeTable = Engine_Api::_()->getDbtable('languages', 'user');
     $type = $typeTable->find($id)->current();
     $form = $this->view->form = new User_Form_Admin_Language_Add();
     $form->setAction($this->getFrontController()->getRouter()->assemble(array()));
     $form->setField($type);
     // Check post
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         // Ok, we're good to add field
         $values = $form->getValues();
         $db = Engine_Db_Table::getDefaultAdapter();
         $db->beginTransaction();
         try {
             $type->title = $values["label"];
             $type->save();
             $db->commit();
         } catch (Exception $e) {
             $db->rollBack();
             throw $e;
         }
         return $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('')));
     }
     // Output
     $this->renderScript('admin-languages/form.tpl');
 }
Esempio n. 14
0
 public function indexAction()
 {
     $tag_table = Engine_Api::_()->getDbtable('tags', 'core');
     $tag_map_table = Engine_Api::_()->getDbtable('tagMaps', 'core');
     $event_table = Engine_Api::_()->getItemTable('event');
     $tag_name = $tag_table->info('name');
     $tag_map_name = $tag_map_table->info('name');
     $event_name = $event_table->info('name');
     $filter_select = $tag_map_table->select()->distinct()->from($tag_map_name, array("{$event_name}.repeat_group", "{$tag_map_name}.tag_id", "{$tag_map_name}.resource_type"))->setIntegrityCheck(false)->joinLeft($event_name, "{$event_name}.event_id = {$tag_map_name}.resource_id", '')->where("{$event_name}.search = ?", "1");
     $select = $tag_table->select()->from($tag_name, array("{$tag_name}.*", "Count({$tag_name}.tag_id) as count"));
     $select->joinLeft($filter_select, "t.tag_id = {$tag_name}.tag_id", '');
     $select->order("count DESC");
     $select->group("{$tag_name}.text");
     $select->where("t.resource_type = ?", "event");
     if (Engine_Api::_()->core()->hasSubject('user')) {
         $user = Engine_Api::_()->core()->getSubject('user');
         $select->where("t.tagger_id = ?", $user->getIdentity());
     } else {
         if (Engine_Api::_()->core()->hasSubject('event')) {
             $event = Engine_Api::_()->core()->getSubject('event');
             $user = $event->getOwner();
             $select->where("t.tagger_id = ?", $user->getIdentity());
         }
     }
     $this->view->tags = $tag_table->fetchAll($select);
 }
Esempio n. 15
0
 public function getTable()
 {
     if (is_null($this->_table)) {
         $this->_table = Engine_Api::_()->getDbtable('ratings', 'video');
     }
     return $this->_table;
 }
Esempio n. 16
0
    public function adminFieldOption($option, $map)
    {
        $parentField = Engine_Api::_()->fields()->getFieldsMeta($option->getFieldType())->getRowMatching('field_id', $option->field_id);
        $parentFieldLabel = $parentField->label;
        $optionId = $option->option_id;
        $optionLabel = $this->view->translate($option->label);
        $key = $map->getKey();
        $translate = Zend_Registry::get('Zend_Translate');
        $translate_extra_questions = $this->view->translate('These extra questions appear when "%1$s" is selected for "%2$s".', array($optionLabel, $parentFieldLabel));
        $depWrapperClass = 'admin_field_dependent_field_wrapper ' . 'admin_field_dependent_field_wrapper_' . $optionId . ' ' . $this->_generateClassNames($key, 'admin_field_dependent_field_wrapper_');
        $content = <<<EOF
  <div class="{$depWrapperClass}" id="admin_field_dependent_field_wrapper_{$key}_{$optionId}">
    <span class="field_extraoptions_explain">
      {$translate_extra_questions}
      <span>
      [ <a class="dep_add_field_link" href="javascript:void(0);">{$translate->_("add question")}</a> ]
      &nbsp;
      [ <a class="dep_hide_field_link" href="javascript:void(0);" onclick="void(0);" onmousedown="void(0);">{$translate->_("hide questions")}</a> ]
      </span>
    </span>
EOF;
        $dependentMaps = Engine_Api::_()->fields()->getFieldsMaps($option->getFieldType())->getRowsMatching('option_id', $option->option_id);
        //if( !empty($dependentFields) ) {
        $content .= '<ul class="admin_fields">';
        foreach ($dependentMaps as $map) {
            $content .= $this->view->adminFieldMeta($map);
        }
        $content .= '</ul>';
        //}
        $content .= "</div>";
        return $content;
    }
Esempio n. 17
0
 public function indexAction()
 {
     parent::indexAction();
     $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('profilecompleteness_admin_main', array(), 'profilecompleteness_admin_main_manage');
     $type_id = 1;
     $option_id = $this->_getParam('option_id');
     if (empty($option_id)) {
         $option_id = 1;
     }
     $this->view->option_id = $option_id;
     $table = new ProfileCompleteness_Model_DbTable_Weights();
     $db = $table->getAdapter();
     $select = $table->select()->setIntegrityCheck(false);
     $maptable = $db->select()->from(array('map' => 'engine4_user_fields_maps'))->from(array('meta' => 'engine4_user_fields_meta'), array())->where("map.child_id = meta.field_id AND meta.TYPE != 'heading'")->where('map.field_id=?', $type_id)->where('map.option_id = ?', $option_id);
     $result = $db->select()->from(array('m' => $maptable), array('m.option_id', 'm.child_id'))->joinleft(array('w' => 'engine4_profilecompleteness_weights'), 'm.`child_id` = w.`field_id`', array('w.field_id'))->where('w.field_id IS NULL');
     $select->from(array('r' => $result));
     $rows = $table->fetchAll($select);
     if (count($rows) != 0) {
         $db = $table->getAdapter();
         $db->beginTransaction();
         foreach ($rows as $row) {
             $values = array('field_id' => $row->child_id, 'weight' => 1, 'type_id' => $row->option_id);
             $row = $table->createRow();
             $row->setFromArray($values);
             $row->save();
         }
         $db->commit();
     }
     $this->view->type = $option_id;
 }
Esempio n. 18
0
 public function indexAction()
 {
     // Don't render this if not authorized
     $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();
     if (!Engine_Api::_()->core()->hasSubject()) {
         return $this->setNoRender();
     }
     // Get subject and check auth
     $subject = Engine_Api::_()->core()->getSubject('event');
     if (!$subject->authorization()->isAllowed($viewer, 'view')) {
         return $this->setNoRender();
     }
     // Prepare data
     $this->view->event = $event = $subject;
     $limit = $this->_getParam('max', 5);
     $currentDay = date('Y') . '-' . date('m') . '-' . date('d');
     $table = Engine_Api::_()->getItemTable('event');
     $select = $table->select()->where('category_id = ?', $event->category_id)->where('event_id != ?', $event->getIdentity())->order("DATEDIFF('{$currentDay}', starttime) DESC")->limit($limit);
     $showedEvents = $table->fetchAll($select);
     $this->view->showedEvents = $showedEvents;
     // Hide if nothing to show
     if (count($showedEvents) <= 0) {
         return $this->setNoRender();
     }
 }
Esempio n. 19
0
 public function init()
 {
     $this->clearDecorators()->addDecorator('FormElements')->addDecorator('Form')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'search'))->addDecorator('HtmlTag2', array('tag' => 'div', 'class' => 'clear'));
     $this->setAttribs(array('id' => 'filter_form', 'class' => 'global_form_box'));
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel('Username')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'));
     $email = new Zend_Form_Element_Text('email');
     $email->setLabel('Email')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'));
     $levelMultiOptions = array(0 => ' ');
     /*      $table = $this->_helper->api()->getItemTable('user');
           $select = $viewer->membership()->getMembersSelect('user_id');
           $friends = $table->fetchAll($select);*/
     $levels = Engine_Api::_()->getDbtable('levels', 'authorization')->fetchAll();
     foreach ($levels as $row) {
         $levelMultiOptions[$row->level_id] = $row->getTitle();
     }
     $level_id = new Zend_Form_Element_Select('level_id');
     $level_id->setLabel('Level')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'))->setMultiOptions($levelMultiOptions);
     $enabled = new Zend_Form_Element_Select('enabled');
     $enabled->setLabel('Approved')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'))->setMultiOptions(array('-1' => '', '0' => 'Not Approved', '1' => 'Approved'))->setValue('-1');
     $submit = new Zend_Form_Element_Button('search', array('type' => 'submit'));
     $submit->setLabel('Search')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'buttons'))->addDecorator('HtmlTag2', array('tag' => 'div'));
     $this->addElement('Hidden', 'order', array('order' => 10001));
     $this->addElement('Hidden', 'order_direction', array('order' => 10002));
     $this->addElements(array($username, $email, $level_id, $enabled, $submit));
     // Set default action
     $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
 }
Esempio n. 20
0
 public function denyAction()
 {
     // In smoothbox
     $this->_helper->layout->setLayout('admin-simple');
     $request = Engine_Api::_()->getItem('advgroup_request', $this->_getParam('req_id'));
     $id = $this->_getParam('id');
     $this->view->group_id = $id;
     // Check post
     if ($this->getRequest()->isPost()) {
         $db = Engine_Db_Table::getDefaultAdapter();
         $db->beginTransaction();
         try {
             $group = Engine_Api::_()->getItem('group', $id);
             if ($group) {
                 $group->requested = false;
                 $group->save();
             }
             if ($request) {
                 $request->status = 2;
                 $request->save();
             }
             $db->commit();
         } catch (Exception $e) {
             $db->rollBack();
             throw $e;
         }
         $notifyApi = Engine_Api::_()->getDbtable('notifications', 'activity');
         $notifyApi->addNotification($group->getOwner(), $group, $group, 'advgroup_request_denied');
         $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('')));
     }
     // Output
     $this->renderScript('admin-request/deny.tpl');
 }
Esempio n. 21
0
 public function indexAction()
 {
     $viewer = Engine_Api::_()->user()->getViewer();
     if (empty($viewer)) {
         return $this->setNoRender();
     }
 }
Esempio n. 22
0
 public function createFile($file, $params)
 {
     $space_limit = (int) Engine_Api::_()->getApi('settings', 'core')->getSetting('core_general_quota', 0);
     $tableName = $this->info('name');
     // fetch user
     if (!empty($params['user_id']) && null != ($user = Engine_Api::_()->getItem('user', $params['user_id']))) {
         $user_id = $user->getIdentity();
         $level_id = $user->level_id;
     } else {
         if (null != ($user = Engine_Api::_()->user()->getViewer())) {
             $user_id = $user->getIdentity();
             $level_id = $user->level_id;
         } else {
             $user_id = null;
             $level_id = null;
         }
     }
     // member level quota
     if (null !== $user_id && null !== $level_id) {
         $space_limit = (int) Engine_Api::_()->authorization()->getPermission($level_id, 'user', 'quota');
         $space_used = (int) $this->select()->from($tableName, new Zend_Db_Expr('SUM(size) AS space_used'))->where("user_id = ?", (int) $user_id)->query()->fetchColumn(0);
         $space_required = is_array($file) && isset($file['tmp_name']) ? filesize($file['tmp_name']) : filesize($file);
         if ($space_limit > 0 && $space_limit < $space_used + $space_required) {
             throw new Engine_Exception("File creation failed. You may be over your " . "upload limit. Try uploading a smaller file, or delete some files to " . "free up space. ", self::SPACE_LIMIT_REACHED_CODE);
         }
     }
     $row = $this->createRow();
     $row->setFromArray($params);
     $row->store($file);
     return $row;
 }
Esempio n. 23
0
 public function isVideoUpload()
 {
     $table = Engine_Api::_()->getItemTable("video");
     $viewer = Engine_Api::_()->user()->getViewer();
     $select = $table->select()->where("owner_id = ?", $viewer->getIdentity())->limit(1);
     return $table->fetchRow($select);
 }
Esempio n. 24
0
 public function indexAction()
 {
     // Don't render this if not authorized
     $viewer = Engine_Api::_()->user()->getViewer();
     if (!Engine_Api::_()->core()->hasSubject()) {
         return $this->setNoRender();
     }
     // Get subject and check auth
     $subject = Engine_Api::_()->core()->getSubject('group');
     if (!$subject->authorization()->isAllowed($viewer, 'view')) {
         return $this->setNoRender();
     }
     // Get paginator
     $table = Engine_Api::_()->getItemTable('advgroup_topic');
     $select = $table->select()->where('group_id = ?', Engine_Api::_()->core()->getSubject()->getIdentity())->order('post_count DESC');
     $this->view->paginator = $paginator = Zend_Paginator::factory($select);
     // Set item count per page and current page number
     $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 5));
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     // Do not render if nothing to show and not viewer
     if ($paginator->getTotalItemCount() <= 0 && !$viewer->getIdentity()) {
         return $this->setNoRender();
     }
     $this->view->canPost = Engine_Api::_()->authorization()->isAllowed($subject, $viewer, 'comment');
     // Add count to title if configured
     //    if( $this->_getParam('titleCount', false) && $paginator->getTotalItemCount() > 0 ) {
     //      $this->_childCount = $paginator->getTotalItemCount();
     //    }
 }
Esempio n. 25
0
 public function init()
 {
     $this->clearDecorators()->addDecorator('FormElements')->addDecorator('Form')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'search'))->addDecorator('HtmlTag2', array('tag' => 'div', 'class' => 'clear'));
     $this->setAttribs(array('id' => 'filter_form', 'class' => 'global_form_box'))->setMethod('GET');
     $displayname = new Zend_Form_Element_Text('displayname');
     $displayname->setLabel('Display Name')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'));
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel('Username')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'));
     $email = new Zend_Form_Element_Text('email');
     $email->setLabel('Email')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'));
     $levels = Engine_Api::_()->getDbtable('levels', 'authorization')->getLevelsAssoc();
     $levelMultiOptions = array(0 => ' ');
     foreach ($levels as $key => $value) {
         $levelMultiOptions[$key] = $value;
     }
     $level_id = new Zend_Form_Element_Select('level_id');
     $level_id->setLabel('Level')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'))->setMultiOptions($levelMultiOptions);
     $enabled = new Zend_Form_Element_Select('enabled');
     $enabled->setLabel('Approved')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('Label', array('tag' => null, 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div'))->setMultiOptions(array('-1' => '', '0' => 'Not Approved', '1' => 'Approved'))->setValue('-1');
     $submit = new Zend_Form_Element_Button('search', array('type' => 'submit'));
     $submit->setLabel('Search')->clearDecorators()->addDecorator('ViewHelper')->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'buttons'))->addDecorator('HtmlTag2', array('tag' => 'div'));
     $this->addElement('Hidden', 'order', array('order' => 10001));
     $this->addElement('Hidden', 'order_direction', array('order' => 10002));
     $this->addElement('Hidden', 'user_id', array('order' => 10003));
     $this->addElements(array($displayname, $username, $email, $level_id, $enabled, $submit));
     // Set default action without URL-specified params
     $params = array();
     foreach (array_keys($this->getValues()) as $key) {
         $params[$key] = null;
     }
     $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble($params));
 }
Esempio n. 26
0
 public function init()
 {
     $this->setTitle('Reply')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('action' => 'post', 'controller' => 'topic'), 'event_extended', true));
     $viewer = Engine_Api::_()->user()->getViewer();
     $settings = Engine_Api::_()->getApi('settings', 'core');
     $allowHtml = (bool) $settings->getSetting('event_html', 0);
     $allowBbcode = (bool) $settings->getSetting('event_bbcode', 0);
     if (!$allowHtml) {
         $filter = new Engine_Filter_HtmlSpecialChars();
     } else {
         $filter = new Engine_Filter_Html();
         $filter->setForbiddenTags();
         $allowed_tags = array_map('trim', explode(',', Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'event', 'commentHtml')));
         $filter->setAllowedTags($allowed_tags);
     }
     if ($allowHtml || $allowBbcode) {
         $upload_url = "";
         if (Engine_Api::_()->authorization()->isAllowed('album', $viewer, 'create')) {
             $upload_url = Zend_Controller_Front::getInstance()->getRouter()->assemble(array('action' => 'upload-photo'), 'event_photo', true);
         }
         $editorOptions = array('upload_url' => $upload_url, 'bbcode' => $settings->getSetting('forum_bbcode', 0), 'html' => $settings->getSetting('forum_html', 0));
         if (!empty($upload_url)) {
             $editorOptions['plugins'] = array('table', 'fullscreen', 'media', 'preview', 'paste', 'code', 'image', 'textcolor', 'jbimages', 'link');
             $editorOptions['toolbar1'] = array('undo', 'redo', 'removeformat', 'pastetext', '|', 'code', 'media', 'image', 'jbimages', 'link', 'fullscreen', 'preview');
         }
         $this->addElement('TinyMce', 'body', array('disableLoadDefaultDecorators' => true, 'editorOptions' => $editorOptions, 'required' => true, 'allowEmpty' => false, 'decorators' => array('ViewHelper'), 'filters' => array($filter, new Engine_Filter_Censor())));
     } else {
         $this->addElement('Textarea', 'body', array('label' => 'Body', 'allowEmpty' => false, 'required' => true, 'filters' => array(new Engine_Filter_HtmlSpecialChars(), new Engine_Filter_Censor())));
     }
     $this->addElement('Checkbox', 'watch', array('label' => 'Send me notifications when other members reply to this topic.', 'value' => '1'));
     $this->addElement('Button', 'submit', array('label' => 'Post Reply', 'ignore' => true, 'type' => 'submit'));
     $this->addElement('Hidden', 'topic_id', array('order' => '920', 'filters' => array('Int')));
     $this->addElement('Hidden', 'ref');
 }
Esempio n. 27
0
 public function indexAction()
 {
     $subject = Engine_Api::_()->core()->getSubject();
     $viewer = Engine_Api::_()->user()->getViewer();
     if (!$this->_helper->requireAuth()->setAuthParams('event', null, 'view')->isValid()) {
         return;
     }
     // Check block
     if ($viewer->isBlockedBy($subject)) {
         return $this->_forward('requireauth', 'error', 'core');
     }
     // Increment view count
     if (!$subject->getOwner()->isSelf($viewer)) {
         $subject->view_count++;
         $subject->save();
     }
     // Get styles
     $table = Engine_Api::_()->getDbtable('styles', 'core');
     $select = $table->select()->where('type = ?', $subject->getType())->where('id = ?', $subject->getIdentity())->limit();
     $row = $table->fetchRow($select);
     if (null !== $row && !empty($row->style)) {
         $this->view->headStyle()->appendStyle($row->style);
     }
     // Render
     $this->_helper->content->setNoRender()->setEnabled();
 }
Esempio n. 28
0
 public function indexAction()
 {
     // Don't render this if not authorized
     $viewer = Engine_Api::_()->user()->getViewer();
     if (!Engine_Api::_()->core()->hasSubject()) {
         return $this->setNoRender();
     }
     // Get subject and check auth
     $subject = Engine_Api::_()->core()->getSubject('group');
     if (!$subject->authorization()->isAllowed($viewer, 'view')) {
         return $this->setNoRender();
     }
     // Get paginator
     $album = $subject->getSingletonAlbum();
     $this->view->paginator = $paginator = $album->getCollectiblesPaginator();
     $this->view->canUpload = $canUpload = $subject->authorization()->isAllowed(null, 'photo');
     // Set item count per page and current page number
     $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 8));
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     // Do not render if nothing to show and cannot upload
     if ($paginator->getTotalItemCount() <= 0 && !$canUpload) {
         return $this->setNoRender();
     }
     // Add count to title if configured
     if ($this->_getParam('titleCount', false) && $paginator->getTotalItemCount() > 0) {
         $this->_childCount = $paginator->getTotalItemCount();
     }
 }
Esempio n. 29
0
 public function deleteAction()
 {
     $viewer = Engine_Api::_()->user()->getViewer();
     $link = Engine_Api::_()->getItem('core_link', $this->getRequest()->getParam('link_id'));
     if (!$this->_helper->requireAuth()->setAuthParams($link, null, 'delete')->isValid()) {
         return;
     }
     $this->view->form = $form = new Core_Form_Link_Delete();
     $translate = Zend_Registry::get('Zend_Translate');
     if (!$link) {
         $this->view->status = false;
         $this->view->error = Zend_Registry::get('Zend_Translate')->_("Link doesn't exists or not authorized to delete");
         return;
     }
     if (!$this->getRequest()->isPost()) {
         $this->view->status = false;
         $this->view->error = Zend_Registry::get('Zend_Translate')->_('Invalid request method');
         return;
     }
     $db = $link->getTable()->getAdapter();
     $db->beginTransaction();
     try {
         $link->delete();
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         throw $e;
     }
     $this->view->status = true;
     $this->view->message = Zend_Registry::get('Zend_Translate')->_('Link has been deleted.');
     return $this->_forward('success', 'utility', 'core', array('parentRefresh' => true, 'messages' => array(Zend_Registry::get('Zend_Translate')->_('Link has been deleted.'))));
 }
Esempio n. 30
0
 public function setPhoto($photo)
 {
     if ($photo instanceof Zend_Form_Element_File) {
         $file = $photo->getFileName();
     } else {
         if (is_array($photo) && !empty($photo['tmp_name'])) {
             $file = $photo['tmp_name'];
         } else {
             if (is_string($photo) && file_exists($photo)) {
                 $file = $photo;
             } else {
                 throw new Event_Model_Exception('invalid argument passed to setPhoto');
             }
         }
     }
     $name = basename($file);
     $path = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'temporary';
     $params = array('parent_id' => $this->getIdentity(), 'parent_type' => 'ynfeed');
     // Save
     $storage = Engine_Api::_()->storage();
     // Resize image (icon)
     $image = Engine_Image::factory();
     $image->open($file)->resize(16, 16)->write($path . '/ic_' . $name)->destroy();
     // Store
     $iMain = $storage->create($path . '/ic_' . $name, $params);
     // Remove temp files
     @unlink($path . '/ic_' . $name);
     // Update row
     $this->photo_id = $iMain->file_id;
     $this->save();
     return $this;
 }