public function deleteAction() { if (!$this->_helper->requireAuth()->setAuthParams('ynsocialads_campaign', null, 'delete')->isValid()) { return; } // In smoothbox $this->_helper->layout->setLayout('admin-simple'); $id = $this->_getParam('id'); $campaign = Engine_Api::_()->getItem('ynsocialads_campaign', $id); if (!$campaign->isDeletable()) { return; } $this->view->campaign_id = $id; // Check post if ($this->getRequest()->isPost()) { $db = Engine_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { $campaign->deleteAllAds(); $campaign->status = "deleted"; $campaign->save(); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array(''))); } }
public function editAction() { // In smoothbox $this->_helper->layout->setLayout('admin-simple'); $id = $this->_getParam('id', 0); $location = Engine_Api::_()->getItem('user_location', $id); if (!$id || !$location) { return $this->_helper->requireSubject()->forward(); } $form = $this->view->form = new User_Form_Admin_Location_Add(); $form->setAction($this->getFrontController()->getRouter()->assemble(array())); $form->setField($location); if ($location->level) { $form->removeElement('continent'); } // 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 { $location->title = $values["title"]; if ($location->level == 0) { $location->continent = $values['continent']; } $location->save(); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } return $this->_forward('success', 'utility', 'core', array('smoothboxClose' => true, 'parentRefresh' => true, 'messages' => array('Edit successfully!'))); } }
public function __construct($config = array()) { if (get_class($this) !== 'Ynfeedback_Model_DbTable_Likes') { $this->_custom = true; } parent::__construct($config); }
public function init() { $this->setMethod('POST'); $defaultArgs = array('disableLoadDefaultDecorators' => true, 'decorators' => array('ViewHelper')); $identity = $this->getAttrib('user_id'); $user_object = Engine_Api::_()->user()->getUser($identity); $user_id = new Zend_Form_Element_Hidden('user_id'); $user_id->setValue($identity); $email = new Zend_Form_Element_Text('email', $defaultArgs); $email->addValidator('emailAddress', true)->addValidator(new Zend_Validate_Db_NoRecordExists(Engine_Db_Table::getTablePrefix() . 'users', 'email')); $email->setValue($user_object->email); $password = new Zend_Form_Element_Password('password', $defaultArgs); $password->addValidator('stringLength', false, array(6, 32)); $passconf = new User_Form_Element_PasswordConfirm('passconf', $defaultArgs); //$passconf->addDecorator('ViewHelper'); if ($settings->getSetting('user.signup.username', 1) > 0) { $username = new Zend_Form_Element_Text('username', $defaultArgs); $username->setValue($user_object->username); $username->addValidator('stringLength', true, array(6, 32))->addValidator(new Zend_Validate_Db_NoRecordExists(Engine_Db_Table::getTablePrefix() . 'users', 'username')); } $language = new Zend_Form_Element_Select('language', $defaultArgs); $language->addMultiOptions(array('English', 'post-English')); $language->setValue($user_object->language_id); $level_id = new Zend_Form_Element_Select('level_id', $defaultArgs); $level_id->setValue($user_object->level_id); $levels = Engine_Api::_()->authorization()->getLevelInfo(); foreach ($levels as $level) { $level_id->addMultiOption($level['level_id'], $level['title']); } $this->addElements(array($user_id, $email, $password, $passconf, $username, $level_id, $language)); }
public function deleteContentAction() { // In smoothbox $this->_helper->layout->setLayout('admin-simple'); $content_id = $this->_getParam('content_id'); $this->view->content_id = $content_id; // Check post if ($this->getRequest()->isPost()) { $db = Engine_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { $content = Engine_Api::_()->getItem('ynfeed_welcome', $content_id); if ($content) { $content->delete(); } $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array(''))); } // Output $this->renderScript('admin-welcome/delete.tpl'); }
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'); }
public function init() { $settings = Engine_Api::_()->getApi('settings', 'core'); $this->setTitle('SignUp - Required Info'); // Init email $this->addElement('Text', 'email', array('label' => 'Email Address', 'description' => 'You will use your email address to login.', 'required' => true, 'allowEmpty' => false, 'tabindex' => $tabIndex++, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email'))))); $this->email->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound'); // Add banned email validator $bannedEmailValidator = new Engine_Validate_Callback(array($this, 'checkBannedEmail'), $emailElement); $bannedEmailValidator->setMessage("This email address is not available, please use another one."); $this->email->addValidator($bannedEmailValidator); if ($settings->getSetting('socialconnect.inputpassword', 0)) { // Element: password $this->addElement('Password', 'password', array('label' => 'Password', 'description' => 'Passwords must be at least 6 characters in length.', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('StringLength', false, array(6, 32))), 'tabindex' => $tabIndex++)); $this->password->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->password->getValidator('NotEmpty')->setMessage('Please enter a valid password.', 'isEmpty'); // Element: passconf $this->addElement('Password', 'passconf', array('label' => 'Password Again', 'description' => 'Enter your password again for confirmation.', 'required' => true, 'validators' => array(array('NotEmpty', true)), 'tabindex' => $tabIndex++)); $this->passconf->getDecorator('Description')->setOptions(array('placement' => 'APPEND')); $this->passconf->getValidator('NotEmpty')->setMessage('Please make sure the "password" and "password again" fields match.', 'isEmpty'); $specialValidator = new Engine_Validate_Callback(array($this, 'checkPasswordConfirm'), $this->password); $specialValidator->setMessage('Password did not match', 'invalid'); $this->passconf->addValidator($specialValidator); } // Init submit $this->addElement('Button', 'submit', array('label' => 'Continue', 'type' => 'submit', 'ignore' => true)); }
public function indexAction() { if (!Engine_Api::_()->core()->hasSubject()) { return $this->setNoRender(); } if (!($group = Engine_Api::_()->core()->getSubject('group'))) { return $this->setNoRender(); } $viewer = Engine_Api::_()->user()->getViewer(); if (!$group->authorization()->isAllowed($viewer, "view")) { return $this->setNoRender(); } if ($this->_getParam('number') != '' && $this->_getParam('number') >= 0) { $limit = $this->_getParam('number'); } else { $limit = 5; } $db = Engine_Db_Table::getDefaultAdapter(); $db->beginTransaction(); $select = "SELECT count(*) as post_count, `result`.subject_id FROM ((SELECT type1.`action_id` , type1.`subject_id` , 'action' as 'type'\n FROM engine4_activity_actions type1\n WHERE object_type = 'group' and object_id = {$group->getIdentity()})\n UNION (\n SELECT like1.`action_id` , like2.`poster_id` as 'subject_id' , 'like' as 'type'\n FROM engine4_activity_likes like2\n JOIN engine4_activity_actions like1 ON like2.resource_id = like1.action_id\n WHERE like1.object_type = 'group'\n AND like1.object_id = {$group->getIdentity()})\n UNION (\n SELECT com1.`action_id`, com2.`poster_id` as 'subject_id' , 'comment' as 'type'\n FROM engine4_activity_comments com2\n JOIN engine4_activity_actions com1 ON com2.resource_id = com1.action_id\n WHERE com1.object_type = 'group'\n AND com1.object_id = {$group->getIdentity()}\n )\n ) as `result`\n GROUP BY `result`.subject_id\n ORDER BY post_count DESC"; $results = $db->fetchAll($select); $this->view->limit = $limit; $this->view->group = $group; $this->view->results = $results; // Do not render if nothing to show if (count($results) <= 0) { return $this->setNoRender(); } }
public function editAction() { // In smoothbox $this->_helper->layout->setLayout('admin-simple'); $id = $this->_getParam('id'); $this->view->campaign_id = $id; // Check post if ($this->getRequest()->isPost()) { $newTitle = strip_tags($this->getRequest()->getPost('newTitle')); $db = Engine_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { $campaign = Engine_Api::_()->getItem('ynsocialads_campaign', $id); $campaign->title = $newTitle; $campaign->save(); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array(''))); } // Output $this->renderScript('admin-campaigns/edit.tpl'); }
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'); }
public function __construct($config = array()) { if (get_class($this) !== 'Core_Model_DbTable_Comments') { $this->_custom = true; } parent::__construct($config); }
public function getDb() { if ($this->_db == null) { $this->_db = Engine_Db_Table::getDefaultAdapter(); } return $this->_db; }
public function emailAction() { // In smoothbox $this->_helper->layout->setLayout('admin-simple'); $id = $this->_getParam('id'); $this->view->request_id = $id; // Check post if ($this->getRequest()->isPost()) { $table = Engine_Api::_()->getDbTable('inviterequests', 'user'); $db = Engine_Db_Table::getDefaultAdapter(); $db->beginTransaction(); $post = $this->getRequest()->getPost(); try { $viewer = Engine_Api::_()->user()->getViewer(); $request = Engine_Api::_()->getItem('user_inviterequest', $id); $message = trim($post['message']); $mailType = 'user_email_request'; $mailParams = array('host' => $_SERVER['HTTP_HOST'], 'email' => $email, 'date' => time(), 'sender_email' => $request->email, 'sender_title' => $viewer->getTitle(), 'sender_link' => $viewer->getHref(), 'message' => $message); Engine_Api::_()->getApi('mail', 'core')->sendSystem($request->email, $mailType, $mailParams); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->_forward('success', 'utility', 'core', array('smoothboxClose' => true, 'parentRefresh' => true, 'messages' => array('Email has been sent to requester.'))); } }
public function onItemDeleteBefore($event) { $item = $event->getPayload(); if ($item instanceof Core_Model_Item_Abstract) { $db = Engine_Db_Table::getDefaultAdapter(); $db->delete('engine4_seo_pages', array('page_id = ?' => $item->getGuid())); } }
public function __construct($config = array()) { if (!isset($this->_rowClass)) { $this->_rowClass = Engine_Api::_()->getItemClass($this->getItemType()); } // @todo stuff parent::__construct($config); }
public function deleteNode($node, $moveToId = 0) { $moveToId = (int) $moveToId; $db = Engine_Db_Table::getDefaultAdapter(); $ids = $node->getAllChildrenIds(); $db->update('engine4_event_events', array('category_id' => $moveToId), 'category_id IN(' . implode(',', $ids) . ')'); $db->delete('engine4_event_categories', 'category_id IN(' . implode(',', $ids) . ')'); }
public function denyAction() { $id = $this->_getParam('id'); $array_id = $this->_getParam('array_id'); $reasonTable = Engine_Api::_()->getItemTable('slprofileverify_reason'); $this->view->reasons = $reasonTable->fetchAll(); $type = $this->_getParam('type'); if ($type != "unverifying") { $type = "denied"; } $this->view->type = $type; if ($this->getRequest()->isPost()) { $values = $this->getRequest()->getPost(); if (!isset($values['reason']) && !isset($values['other'])) { $this->view->error_reason = 1; return; } if (empty($values['content']) && isset($values['other'])) { $this->view->error_reason = 2; return; } $messages = "<ul style='list-style: square inside none;'>"; if (isset($values['reason'])) { foreach ($values['reason'] as $reason_id) { $reason = Engine_Api::_()->getItem('slprofileverify_reason', $reason_id); $messages .= "<li>" . $reason->description . '</li>'; } } if (!empty($values['content'])) { $messages .= "<li>" . $values['content'] . '</li>'; } $messages .= "</ul>"; $db = Engine_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { $settingApi = Engine_Api::_()->getApi('core', 'slprofileverify'); if (!empty($array_id)) { $array_ids = split(",", $array_id); foreach ($array_ids as $id) { if ($id) { $settingApi->verifyUser($id, 'unverified'); $settingApi->sendMailVerify($id, $messages, $type); } } } else { if ($id) { $settingApi->verifyUser($id, 'unverified'); $settingApi->sendMailVerify($id, $messages, $type); } } $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array('successfully'))); } }
public function contactAction() { $translate = Zend_Registry::get('Zend_Translate'); $this->view->form = $form = new Core_Form_Contact(); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Success! Process // Mail gets logged into database, so perform try/catch in this Controller $db = Engine_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { // the contact form is emailed to the first SuperAdmin by default $users_table = Engine_Api::_()->getDbtable('users', 'user'); $users_select = $users_table->select()->where('level_id = ?', 1)->where('enabled >= ?', 1); $super_admin = $users_table->fetchRow($users_select); $viewer = Engine_Api::_()->user()->getViewer(); $values = $form->getValues(); // Check for error report $error_report = ''; $name = $this->_getParam('name'); $loc = $this->_getParam('loc'); $time = $this->_getParam('time'); if ($name && $loc && $time) { $error_report .= "\r\n"; $error_report .= "\r\n"; $error_report .= "-------------------------------------"; $error_report .= "\r\n"; $error_report .= $this->view->translate('The following information about an error was included with this message:'); $error_report .= "\r\n"; $error_report .= $this->view->translate('Exception: ') . base64_decode(urldecode($name)); $error_report .= "\r\n"; $error_report .= $this->view->translate('Location: ') . base64_decode(urldecode($loc)); $error_report .= "\r\n"; $error_report .= $this->view->translate('Time: ') . date('c', base64_decode(urldecode($time))); $error_report .= "\r\n"; } // Make params $mail_settings = array('host' => $_SERVER['HTTP_HOST'], 'email' => $super_admin->email, 'date' => time(), 'recipient_title' => $super_admin->getTitle(), 'recipient_link' => $super_admin->getHref(), 'recipient_photo' => $super_admin->getPhotoUrl('thumb.icon'), 'sender_title' => $values['name'], 'sender_email' => $values['email'], 'message' => $values['body'], 'error_report' => $error_report); if ($viewer && $viewer->getIdentity()) { $mail_settings['sender_title'] .= ' (' . $viewer->getTitle() . ')'; $mail_settings['sender_email'] .= ' (' . $viewer->email . ')'; $mail_settings['sender_link'] = $viewer->getHref(); } // send email Engine_Api::_()->getApi('mail', 'core')->sendSystem($super_admin->email, 'core_contact', $mail_settings); // if the above did not throw an exception, it succeeded $db->commit(); $this->view->status = true; $this->view->message = $translate->_('Thank you for contacting us!'); } catch (Zend_Mail_Transport_Exception $e) { $db->rollBack(); throw $e; } }
public function getAllOutboxSelect($users) { $rName = Engine_Api::_()->getDbtable('recipients', 'messages')->info('name'); $cName = $this->info('name'); $str = implode(",", array_map(array($this, "getFirst"), $users)); $select = "\n SELECT `engine4_messages_conversations`.* FROM `engine4_messages_conversations` \n\t\tRIGHT JOIN (`engine4_messages_recipients` INNER JOIN `engine4_ynbanmem_extramessage` ON `engine4_messages_recipients`.outbox_message_id = `engine4_ynbanmem_extramessage`.message_id) \n\t\tON `engine4_messages_recipients`.`conversation_id` = `engine4_messages_conversations`.`conversation_id` WHERE (`engine4_messages_recipients`.`user_id` IN (" . $str . ")) AND (`engine4_messages_recipients`.`outbox_deleted` = 0) ORDER BY outbox_updated DESC;\n \n "; $db = Engine_Db_Table::getDefaultAdapter(); return $db->fetchAll($select); }
public function __construct($itemType, $tableType, $config = array()) { if (!is_string($itemType) || !is_string($tableType)) { throw new Fields_Model_Exception('Item type and table type must be strings'); } $this->_fieldType = $itemType; $this->_fieldTableType = $tableType; $config['name'] = $itemType . '_fields_' . $tableType; parent::__construct($config); }
public function altUrl(Core_Model_Item_Abstract $item) { $db = Engine_Db_Table::getDefaultAdapter(); if (isset($this->_memo[$item->getGuid()])) { return $this->_memo[$item->getGuid()]; } $url = $db->select()->from('engine4_seo_pages', 'url')->where('page_id = ?', $item->getGuid())->query()->fetchColumn(); $this->_memo[$item->getGuid()] = $url; return $url; }
public function getValues($service) { $return = array(); if (!is_string($service)) { return $return; } $adapter = Engine_Db_Table::getDefaultAdapter(); $sql = "\n select concat('pfid_',t1.field_id) as name, t1.opt_id as value\n from engine4_socialconnect_maps as t1\n where t1.service = '{$service}'"; $rs = $adapter->fetchPairs($sql); return $rs; }
public function init() { // @todo fix form CSS/decorators // @todo replace fake values with real values $this->setTitle('General Settings')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array())); // Init email $this->addElement('Text', 'email', array('label' => 'Email Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity())))))); $this->email->getValidator('NotEmpty')->setMessage('Please enter a valid email address.', 'isEmpty'); $this->email->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound'); // Init username $this->addElement('Text', 'username', array('label' => 'Profile Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Alnum', true), array('StringLength', true, array(4, 64)), array('Regex', true, array('/^[a-z0-9]/i')), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'username', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity())))))); $this->username->getValidator('NotEmpty')->setMessage('Please enter a valid profile address.', 'isEmpty'); $this->username->getValidator('Db_NoRecordExists')->setMessage('Someone has already picked this profile address, please use another one.', 'recordFound'); $this->username->getValidator('Regex')->setMessage('Profile addresses must start with a letter.', 'regexNotMatch'); $this->username->getValidator('Alnum')->setMessage('Profile addresses must be alphanumeric.', 'notAlnum'); // Init type $this->addElement('Select', 'accountType', array('label' => 'Account Type')); // Init Facebook $facebook_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_facebook_enable', 'none'); if ('none' != $facebook_enable) { $and_publish = 'publish' == $facebook_enable ? ' and publish content to your Facebook wall.' : '.'; $this->addElement('Dummy', 'facebook', array('label' => 'Facebook Integration', 'description' => 'Linking your Facebook account will let you login with Facebook' . $and_publish, 'content' => User_Model_DbTable_Facebook::loginButton('Integrate with my Facebook'))); $this->addElement('Checkbox', 'facebook_id', array('label' => 'Integrate with my Facebook', 'description' => 'Facebook Integration')); } // Init timezone $this->addElement('Select', 'timezone', array('label' => 'Timezone', 'description' => 'Select the city closest to you that shares your same timezone.', 'multiOptions' => array('US/Pacific' => '(UTC-8) Pacific Time (US & Canada)', 'US/Mountain' => '(UTC-7) Mountain Time (US & Canada)', 'US/Central' => '(UTC-6) Central Time (US & Canada)', 'US/Eastern' => '(UTC-5) Eastern Time (US & Canada)', 'America/Halifax' => '(UTC-4) Atlantic Time (Canada)', 'America/Anchorage' => '(UTC-9) Alaska (US & Canada)', 'Pacific/Honolulu' => '(UTC-10) Hawaii (US)', 'Pacific/Samoa' => '(UTC-11) Midway Island, Samoa', 'Etc/GMT-12' => '(UTC-12) Eniwetok, Kwajalein', 'Canada/Newfoundland' => '(UTC-3:30) Canada/Newfoundland', 'America/Buenos_Aires' => '(UTC-3) Brasilia, Buenos Aires, Georgetown', 'Atlantic/South_Georgia' => '(UTC-2) Mid-Atlantic', 'Atlantic/Azores' => '(UTC-1) Azores, Cape Verde Is.', 'Europe/London' => 'Greenwich Mean Time (Lisbon, London)', 'Europe/Berlin' => '(UTC+1) Amsterdam, Berlin, Paris, Rome, Madrid', 'Europe/Athens' => '(UTC+2) Athens, Helsinki, Istanbul, Cairo, E. Europe', 'Europe/Moscow' => '(UTC+3) Baghdad, Kuwait, Nairobi, Moscow', 'Iran' => '(UTC+3:30) Tehran', 'Asia/Dubai' => '(UTC+4) Abu Dhabi, Kazan, Muscat', 'Asia/Kabul' => '(UTC+4:30) Kabul', 'Asia/Yekaterinburg' => '(UTC+5) Islamabad, Karachi, Tashkent', 'Asia/Dili' => '(UTC+5:30) Bombay, Calcutta, New Delhi', 'Asia/Katmandu' => '(UTC+5:45) Nepal', 'Asia/Omsk' => '(UTC+6) Almaty, Dhaka', 'India/Cocos' => '(UTC+6:30) Cocos Islands, Yangon', 'Asia/Krasnoyarsk' => '(UTC+7) Bangkok, Jakarta, Hanoi', 'Asia/Hong_Kong' => '(UTC+8) Beijing, Hong Kong, Singapore, Taipei', 'Asia/Tokyo' => '(UTC+9) Tokyo, Osaka, Sapporto, Seoul, Yakutsk', 'Australia/Adelaide' => '(UTC+9:30) Adelaide, Darwin', 'Australia/Sydney' => '(UTC+10) Brisbane, Melbourne, Sydney, Guam', 'Asia/Magadan' => '(UTC+11) Magadan, Soloman Is., New Caledonia', 'Pacific/Auckland' => '(UTC+12) Fiji, Kamchatka, Marshall Is., Wellington'))); // Init default locale $locale = Zend_Registry::get('Locale'); $localeMultiKeys = array_merge(array_keys(Zend_Locale::getLocaleList())); $localeMultiOptions = array(); $languages = Zend_Locale::getTranslationList('language', $locale); $territories = Zend_Locale::getTranslationList('territory', $locale); foreach ($localeMultiKeys as $key) { if (!empty($languages[$key])) { $localeMultiOptions[$key] = $languages[$key]; } else { $locale = new Zend_Locale($key); $region = $locale->getRegion(); $language = $locale->getLanguage(); if (!empty($languages[$language]) && !empty($territories[$region])) { $localeMultiOptions[$key] = $languages[$language] . ' (' . $territories[$region] . ')'; } } } $localeMultiOptions = array_merge(array('auto' => '[Automatic]'), $localeMultiOptions); $this->addElement('Select', 'locale', array('label' => 'Locale', 'description' => 'Dates, times, and other settings will be displayed using this locale setting.', 'multiOptions' => $localeMultiOptions)); // Init submit $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true)); // Create display group for buttons #$this->addDisplayGroup($emailAlerts, 'checkboxes'); // Set default action $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'settings', 'action' => 'general'), 'default')); }
public function init() { $this->setAttrib('id', 'admin_members_edit')->setTitle('Edit Member')->setDescription('You can change the details of this member\'s account here.')->setAction($_SERVER['REQUEST_URI']); // init email $this->addElement('Text', 'email', array('label' => 'Email Address', 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email', array('field' => 'user_id', 'value' => (int) $this->_userIdentity)))), 'filters' => array('StringTrim'))); $this->email->getValidator('EmailAddress')->getHostnameValidator()->setValidateTld(false); // init username if (Engine_Api::_()->getApi('settings', 'core')->getSetting('user.signup.username', 1) > 0) { $this->addElement('Text', 'username', array('label' => 'Username')); } // init password $this->addElement('Password', 'password', array('label' => 'Password')); $this->addElement('Password', 'password_conf', array('label' => 'Password Again')); // Init level $levelMultiOptions = array(); //0 => ' '); $levels = Engine_Api::_()->getDbtable('levels', 'authorization')->fetchAll(); foreach ($levels as $row) { $levelMultiOptions[$row->level_id] = $row->getTitle(); } $this->addElement('Select', 'level_id', array('label' => 'Member Level', 'multiOptions' => $levelMultiOptions)); // Init level $networkMultiOptions = array(); //0 => ' '); $networks = Engine_Api::_()->getDbtable('networks', 'network')->fetchAll(); foreach ($networks as $row) { $networkMultiOptions[$row->network_id] = $row->getTitle(); } $this->addElement('Multiselect', 'network_id', array('label' => 'Networks', 'multiOptions' => $networkMultiOptions)); // Get list of Member Types $db = Engine_Db_Table::getDefaultAdapter(); $member_type_result = $db->select('option_id, label')->from('engine4_user_fields_options')->where('field_id = 1')->query()->fetchAll(); $member_type_count = count($member_type_result); $member_type_array = array(); for ($i = 0; $i < $member_type_count; $i++) { $member_type_array[$member_type_result[$i]['option_id']] = $member_type_result[$i]['label']; } $this->addElement('Select', 'profile_type', array('label' => 'Profile Type', 'multiOptions' => $member_type_array)); // Init approved $this->addElement('Checkbox', 'approved', array('label' => 'Approved?')); // Init verified $this->addElement('Checkbox', 'verified', array('label' => 'Verified?')); // Init enabled $this->addElement('Checkbox', 'enabled', array('label' => 'Enabled?')); // Buttons $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true, 'decorators' => array('ViewHelper'))); $this->addElement('Cancel', 'cancel', array('label' => 'cancel', 'link' => true, 'prependText' => ' or ', 'onclick' => 'parent.Smoothbox.close();', 'decorators' => array('ViewHelper'))); $this->addDisplayGroup(array('submit', 'cancel'), 'buttons'); $button_group = $this->getDisplayGroup('buttons'); $button_group->addDecorator('DivDivDivWrapper'); }
public function mutualFriends($subject, $viewer = null, $limit = 5, $mess1 = '%s follower', $mess2 = '%s followers') { if (null === $viewer) { $viewer = Engine_Api::_()->user()->getViewer(); } if (!$viewer || !$viewer->getIdentity() || $subject->isSelf($viewer)) { return ''; } // check if a & b has mutuals friend. $subject_id = (int) $subject->getIdentity(); $viewer_id = (int) $viewer->getIdentity(); if ($viewer_id == 0 || $subject_id == 0) { return 'sandobox'; } $isFriend = $subject->membership()->isMember($viewer); //if (!$isFriend){'';} // Diff friends $friendsTable = Engine_Api::_()->getDbtable('membership', $subject->getModuleName()); $friendsName = $friendsTable->info('name'); // Mututal friends/following mode $sql = "SELECT `user_id` FROM `{$friendsName}` WHERE (`active`=1 and `resource_id`={$subject_id})"; $db = Engine_Db_Table::getDefaultAdapter(); $friends = $friendsTable->getAdapter()->fetchcol($sql); if (empty($friends)) { return; } // Get paginator $usersTable = Engine_Api::_()->getItemTable('user'); $select = $usersTable->select()->where('user_id IN(?)', $friends)->order('photo_id desc'); $paginator = Zend_Paginator::factory($select); /** * @var int * number of multual friends to show here */ $paginator->setItemCountPerPage($limit); $totalFriends = $paginator->getTotalItemCount(); if ($totalFriends <= 0) { return ''; } $xhtml = array(); $xhtml[] = '<div class="uiYnfbppHovercardSmallInfo">' . $this->view->translate(array($mess1, $mess2, $totalFriends), $this->view->locale()->toNumber($totalFriends)) . '</div>'; $xhtml[] = '<ul class="uiYnfpSmallAvatars">'; foreach ($paginator as $resource) { $xhtml[] = '<li>' . $this->view->htmlLink($resource->getHref(), $this->view->itemPhoto($resource, 'thumb.icon'), array('title' => $resource->getTitle())) . '</li>'; if (--$limit <= 0) { break; } } $xhtml[] = '</ul>'; return implode(PHP_EOL, $xhtml); }
protected function _fetch(Zend_Db_Table_Select $select) { $rows = parent::_fetch($select); foreach ($rows as $index => $data) { // Decrypt each column foreach ($this->_cryptedColumns as $col) { if (!empty($rows[$index][$col])) { $rows[$index][$col] = self::_decrypt($rows[$index][$col]); } } // Unserialize $rows[$index] = $this->_unserializeColumns($rows[$index]); } return $rows; }
public function onInstall() { parent::onInstall(); $this->_ynBuildStructure(); $db_adapter = Engine_Db_Table::getDefaultAdapter(); if ($this->checkModuleExisted('ynidea')) { $sql = "ALTER TABLE `engine4_ynidea_ideas` CHANGE `title` `title` VARCHAR( 256 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; $db_adapter->query($sql); } if ($this->checkModuleExisted('ynwiki')) { $sql = "ALTER TABLE `engine4_ynwiki_pages` CHANGE `title` `title` VARCHAR( 256 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; $db_adapter->query($sql); } //Updating for old version $sql = "UPDATE `engine4_ynmoderation_modules` SET `report_query` = 'SELECT report_id, user_id, `type` AS `category`, `content` AS `description`, \\'ynwiki_page\\' AS `subject_type`, `page_id` AS `subject_id`, creation_date, \\'ynwiki_report\\' AS `report_type` FROM engine4_ynwiki_reports' WHERE `name`='Wiki' AND `object_type`='ynwiki_page'"; $db_adapter->query($sql); }
public function activitySettingsAction() { $modulestable = Engine_Api::_()->getDbtable('modules', 'yncomment'); $modules = $modulestable->fetchRow(array('resource_type = ?' => 'ynfeed')); $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('yncomment_admin_main', array(), 'yncomment_admin_main_activitySettings'); $db = Zend_Db_Table_Abstract::getDefaultAdapter(); $this->view->form = $form = new Yncomment_Form_Admin_ActivityEdit(); //IF NOT POST OR FORM NOT VALID THAN RETURN if (!$this->getRequest()->isPost()) { $val = $modules->toArray(); if ($val['params']) { $decodedParams = Zend_Json_Decoder::decode($val['params']); $form->populate($decodedParams); if (isset($decodedParams['showAsLike'])) { $this->view->showAsLike = $decodedParams['showAsLike']; } if (isset($decodedParams['ynfeed_comment_like_box'])) { $this->view->ynfeed_comment_like_box = $decodedParams['ynfeed_comment_like_box']; } } else { $form->populate($modules->toArray()); } return; } //IF NOT POST OR FORM NOT VALID THAN RETURN if (!$form->isValid($this->getRequest()->getPost())) { return; } //GET FORM VALUES $values = $form->getValues(); $values['module'] = $modules->module; $values['resource_type'] = $modules->resource_type; $db = Engine_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { $modules->setFromArray($values); $modules->save(); $modules->params = Zend_Json_Encoder::encode($values); $modules->save(); $db->commit(); $form->addNotice('Your changes have been saved.'); } catch (Exception $e) { $db->rollBack(); throw $e; } }
public function killAction() { $id = $this->_getParam('video_id', null); if ($this->getRequest()->isPost()) { $db = Engine_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { $video = Engine_Api::_()->getItem('video', $id); $video->status = 3; $video->save(); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } } }
public function indexAction() { $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('contactimporter_admin_main', array(), 'contactimporter_admin_main_settings'); $this->view->form = $form = new Contactimporter_Form_Admin_Global(); if ($this->getRequest()->isPost() && $this->view->form->isValid($this->getRequest()->getPost())) { $db = Engine_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { $this->view->form->saveValues(); $db->commit(); $form->addNotice('Your changes have been saved.'); } catch (Exception $e) { $db->rollback(); throw $e; } } }