public function indexAction() { if ($this->checkModuleExisted('ynidea')) { if (!isset($_SESSION['ynmoderation_checked_idea_collation'])) { $db_adapter = Engine_Db_Table::getDefaultAdapter(); $sql = "ALTER TABLE `engine4_ynidea_ideas` CHANGE `title` `title` VARCHAR( 256 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; $db_adapter->query($sql); $_SESSION['ynmoderation_checked_idea_collation'] = 1; } } if ($this->checkModuleExisted('ynwiki')) { if (!isset($_SESSION['ynmoderation_checked_wiki_collation'])) { $db_adapter = Engine_Db_Table::getDefaultAdapter(); $sql = "ALTER TABLE `engine4_ynwiki_pages` CHANGE `title` `title` VARCHAR( 256 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; $db_adapter->query($sql); $_SESSION['ynmoderation_checked_wiki_collation'] = 1; } } $this->view->formFilter = $formFilter = new Ynmoderation_Form_Admin_Moderations_Filter(); $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('ynmoderation_admin_main', array(), 'ynmoderation_admin_main_moderations'); //Getting Plugins list $type = $this->_getParam('type_id'); $params = array('enabled' => '1'); if (!empty($type) && is_numeric($type)) { $params['id'] = $type; } $pluginTbl = Engine_Api::_()->getDbTable('modules', 'ynmoderation'); $pluginList = $pluginTbl->fetchAll($pluginTbl->getModulesSelect($params)); if (!$formFilter->isValid($this->_getAllParams())) { return; } //Checking Post status for removing data if ($this->getRequest()->isPost()) { $values = $this->getRequest()->getPost(); foreach ($pluginList as $plugin) { $type = $plugin->object_type; if (Engine_Api::_()->hasModuleBootstrap("advalbum") && $type == 'album') { $type = 'advalbum_album'; } else { if (Engine_Api::_()->hasModuleBootstrap("advalbum") && $type == 'album_photo') { $type = 'advalbum_photo'; } } if (is_array($values[$type])) { for ($i = 0; $i < count($values[$type]); $i++) { $id = $values[$type][$i]; $item = Engine_Api::_()->getItem($type, $id); $item->delete(); //Getting moderation module record $tmpPlugin = $pluginTbl->fetchRow($pluginTbl->getModulesSelect(array('object_type' => $type))); if (is_object($tmpPlugin)) { if ($tmpPlugin->report_object_type) { $reportObjType = $tmpPlugin->report_object_type; $reportField = $tmpPlugin->report_field; $reportTbl = Engine_Api::_()->getItemTable($reportObjType); $reportTbl->delete("{$reportField} = {$id}"); } } } } } } //Getting content $modulesObj = new Core_Model_DbTable_Modules(); $db = Engine_Db_Table::getDefaultAdapter(); $select = $db->select(); $unionArr = array(); if (count($pluginList) <= 0) { return; } foreach ($pluginList as $plugin) { if (Engine_Api::_()->hasModuleBootstrap("advalbum") && $plugin->object_type == 'album') { $plugin->object_type = 'advalbum_album'; } else { if (Engine_Api::_()->hasModuleBootstrap("advalbum") && $plugin->object_type == 'album_photo') { $plugin->object_type = 'advalbum_photo'; } } //Checking module is existed/enabled or not if (Engine_Api::_()->hasItemType($plugin->object_type) && $plugin->moderation_query) { $unionArr[] = $plugin->moderation_query; } } if (count($unionArr) == 0) { return; } $select = $select->union($unionArr); $mainSelect = $db->select()->from(array('t' => $select))->limit(500)->order(' t.creation_date DESC '); //Filter content by user $userName = $this->_getParam('username'); if (!empty($userName)) { //$user = Engine_Api::_() -> user() -> getUser($userName); $userTable = new User_Model_DbTable_Users(); $userSelect = $userTable->select()->from($userTable->info('name'), 'user_id')->where(" username = '******' OR displayname = '{$userName}' "); $users = $userTable->fetchAll($userSelect)->toArray(); $uidArr = array(); if (count($users)) { foreach ($users as $user) { $uidArr[] = $user['user_id']; } $mainSelect->where("t.creator IN (?)", $uidArr); } else { $mainSelect->where("t.creator = 0"); } } //Filter content by title $title = $this->_getParam('title'); if (!empty($title)) { $mainSelect->where("t.title LIKE ? ", "%{$title}%"); } $page = $this->_getParam('page', 1); $this->view->paginator = $paginator = Zend_Paginator::factory($mainSelect); $this->view->paginator->setItemCountPerPage(500); $this->view->paginator->setCurrentPageNumber($page); }