public function clearAction() { $this->view->form = $form = new Core_Form_Confirm(array('description' => 'Are you sure you want to clear the login history?', 'submitLabel' => 'Clear History', 'cancelHref' => 'javascript:parent.Smoothbox.close()', 'useToken' => true)); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Delete everything $table = Engine_Api::_()->getDbtable('logins', 'user'); $table->delete('1'); // Forward return $this->_forward('success', 'utility', 'core', array('smoothboxClose' => true, 'parentRefresh' => true, 'format' => 'smoothbox', 'messages' => array('History has been cleared.'))); }
public function transferAction() { // No service ID? if (null === ($service_id = $this->_getParam('service_id'))) { return $this->_helper->redirector->gotoRoute(array('action' => 'index')); } // Make form $this->view->form = $form = new Core_Form_Confirm(array('title' => 'Transfer Files?', 'description' => 'This will begin transferring stored files from other ' . 'services to this storage service.', 'submitLabel' => 'Transfer', 'cancelHref' => $this->view->url(array('action' => 'index', 'service_id' => null)))); $jobsTable = Engine_Api::_()->getDbtable('jobs', 'core'); // Check for existing active job? $activeJobs = $jobsTable->getActiveJobs(array('jobtype' => 'storage_transfer')); if ($activeJobs->count() > 0) { return $form->addError('There is already a pending job to transfer files.'); } // Check if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Process $jobsTable->addJob('storage_transfer', array('service_id' => $service_id)); $form->addNotice('A job has been created to transfer the files.'); }
public function janrainImportAction() { $this->view->form = $form = new Core_Form_Confirm(array('title' => 'Janrain Import', 'description' => 'We will now import the member account associations ' . 'into the Janrain integration. This will allow you to disable ' . 'the original Facebook/Twitter integrations without your ' . 'members losing access to their accounts.')); if (!$form->isValid($this->getRequest()->getPost())) { return; } if (!$this->getRequest()->isPost()) { return; } $db = Engine_Db_Table::getDefaultAdapter(); // Get original row count $prevCount = current($db->fetchCol('SELECT COUNT(user_id) FROM `engine4_user_janrain`')); // Import facebook $sql = "\n INSERT IGNORE INTO `engine4_user_janrain`\n (SELECT \n user_id, \n CONCAT('http://www.facebook.com/profile.php?id=', facebook_uid) as identity, \n 'Facebook' as provider, \n NULL as token \n FROM `engine4_user_facebook`)\n "; $db->query($sql); // Import twitter $sql = "\n INSERT IGNORE INTO `engine4_user_janrain`\n (SELECT \n user_id, \n CONCAT('http://twitter.com/account/profile?user_id=', twitter_uid) as identity, \n 'Twitter' as provider, \n NULL as token \n FROM `engine4_user_twitter`)\n "; $db->query($sql); // Get new row count $newCount = current($db->fetchCol('SELECT COUNT(user_id) FROM `engine4_user_janrain`')); $this->view->notice = $this->view->translate('%1$d records were ' . 'successfully imported. Click ' . '<a href="%2$s">here</a> to return.', $newCount - $prevCount, $this->view->url(array('action' => 'janrain'))); }
public function deleteMenuAction() { $menusTable = Engine_Api::_()->getDbtable('menus', 'core'); $menuItemsTable = Engine_Api::_()->getDbtable('menuItems', 'core'); if ($menu_id = $this->_getParam('menu_id')) { $menu = $menusTable->fetchRow($menusTable->select()->where('menu_id = ?', $menu_id)->where('type = ?', 'custom')); } else { if ($menu_name = $this->_getParam('name')) { $menu = $menusTable->fetchRow($menusTable->select()->where('name = ?', $menu_name)->where('type = ?', 'custom')); } else { $menu = null; } } if (!$menu) { throw new Core_Model_Exception('missing menu'); } // Make form $this->view->form = $form = new Core_Form_Confirm(array('title' => 'Delete Menu?', 'description' => 'Are you sure you want to delete this menu? Please ' . 'make sure you have removed it from any widgets that you have ' . 'added it to in the layout editor.', 'submitLabel' => 'Delete Menu', 'cancelHref' => 'parent.Smoothbox.close()')); // Check stuff if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Process $menuItemsTable->delete(array('menu = ?' => $menu->name)); $menu->delete(); $this->view->form = null; $this->view->status = true; }
public function removeAction() { // Must have a viewer if (!$this->_helper->requireUser()->isValid()) { return; } // Get viewer and subject $viewer = Engine_Api::_()->user()->getViewer(); $user = Engine_Api::_()->core()->getSubject('user'); // Get subscription table $subscriptionTable = Engine_Api::_()->getDbtable('subscriptions', 'ynblog'); // Check if they are already not subscribed if (!$subscriptionTable->checkSubscription($user, $viewer)) { $this->view->status = true; $this->view->message = Zend_Registry::get('Zend_Translate')->_("You are already not subscribed to this member's blog."); return $this->_forward('success', 'utility', 'core', array('parentRefresh' => true, 'messages' => array($this->view->message))); } // Make form $this->view->form = $form = new Core_Form_Confirm(array('title' => 'Unsubscribe?', 'description' => "Would you like to unsubscribe from this member's blog?", 'class' => 'global_form_popup', 'submitLabel' => 'Unsubscribe', 'cancelHref' => 'javascript:parent.Smoothbox.close();')); // Check method if (!$this->getRequest()->isPost()) { return; } // Check valid if (!$form->isValid($this->getRequest()->getPost())) { return; } // Process $db = $user->getTable()->getAdapter(); $db->beginTransaction(); try { $subscriptionTable->removeSubscription($user, $viewer); $db->commit(); } catch (Exception $e) { $db->rollBack(); throw $e; } // Success $this->view->status = true; $this->view->message = Zend_Registry::get('Zend_Translate')->_('You are no longer subscribed to this member\'s blog.'); return $this->_forward('success', 'utility', 'core', array('parentRefresh' => true, 'messages' => array($this->view->message))); }