本文整理汇总了PHP中Engine_Db_Table类的典型用法代码示例。如果您正苦于以下问题:PHP Engine_Db_Table类的具体用法?PHP Engine_Db_Table怎么用?PHP Engine_Db_Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Engine_Db_Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteAction
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('')));
}
}
示例2: editAction
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!')));
}
}
示例3: init
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));
}
示例4: deleteContentAction
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');
}
示例5: editAction
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');
}
示例6: init
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));
}
示例7: indexAction
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();
}
}
示例8: editAction
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');
}
示例9: denyAction
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');
}
示例10: getDb
public function getDb()
{
if ($this->_db == null) {
$this->_db = Engine_Db_Table::getDefaultAdapter();
}
return $this->_db;
}
示例11: emailAction
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.')));
}
}
示例12: onItemDeleteBefore
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()));
}
}
示例13: deleteNode
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) . ')');
}
示例14: denyAction
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')));
}
}
示例15: contactAction
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;
}
}