Example #1
0
 public function _initTriggers()
 {
     $forgotTrigger = new Ot_Trigger_Event('Login_Index_Forgot', 'Forgot Your Password', 'When a user has forgotten their password, they ask for a reset email to be sent to their registered email address.');
     $forgotTrigger->addOption('firstName', 'First name of the user')->addOption('lastName', 'Last name of the user.')->addOption('emailAddress', 'Email address of the user.')->addOption('username', 'Username of user.')->addOption('loginMethod', 'Name of login method which they use to log into the system with.')->addOption('resetUrl', 'URL the user will need to go to to reset their password.');
     $signupTrigger = new Ot_Trigger_Event('Login_Index_Signup', 'Signup for a new account', 'When a user signs up for a new account.');
     $signupTrigger->addOption('firstName', 'First name of the user.')->addOption('lastName', 'Last name of the user.')->addOption('emailAddress', 'Email address of the user.')->addOption('username', 'Username of user.')->addOption('loginMethod', 'Name of login method which they use to log into the system with.')->addOption('password', 'The password they give to their account.');
     $createPassword = new Ot_Trigger_Event('Admin_Account_Create_Password', 'Admin created an account with a password', 'When an administrator creates an account for a user where a password is dynamically generated for the user.');
     $createPassword->addOption('firstName', 'First name of the user.')->addOption('lastName', 'Last name of the user.')->addOption('emailAddress', 'Email address of the user.')->addOption('username', 'Username of user.')->addOption('loginMethod', 'Name of login method which they use to log into the system with.')->addOption('password', 'The password they give to their account.')->addOption('role', 'Assigned role given to the user.');
     $noPassword = new Ot_Trigger_Event('Admin_Account_Create_NoPassword', 'Admin created an account with no password', 'When an administrator creates an account for a user when no password is created for the user.');
     $noPassword->addOption('firstName', 'First name of the user.')->addOption('lastName', 'Last name of the user.')->addOption('emailAddress', 'Email address of the user.')->addOption('username', 'Username of user.')->addOption('loginMethod', 'Name of login method which they use to log into the system with.')->addOption('role', 'Assigned role given to the user.');
     $register = new Ot_Trigger_EventRegister();
     $register->registerTriggerEvents(array($forgotTrigger, $signupTrigger, $createPassword, $noPassword));
 }
 public function copyAction()
 {
     $triggerActionId = $this->_getParam('triggerActionId', null);
     if (is_null($triggerActionId)) {
         throw new Ot_Exception_Input('msg-error-triggerActionIdNotFound');
     }
     $action = new Ot_Model_DbTable_TriggerAction();
     $thisTriggerAction = $action->find($triggerActionId);
     if (is_null($thisTriggerAction)) {
         throw new Ot_Exception_Data('msg-error-noTriggerActionId');
     }
     $register = new Ot_Trigger_EventRegister();
     $thisTriggerEvent = $register->getTriggerEvent($thisTriggerAction->eventKey);
     if (is_null($thisTriggerEvent)) {
         throw new Ot_Exception_Data('msg-error-noTrigger');
     }
     $actionTypeRegister = new Ot_Trigger_ActionTypeRegister();
     $thisActionType = $actionTypeRegister->getTriggerActionType($thisTriggerAction->actionKey);
     if (is_null($thisActionType)) {
         throw new Ot_Exception_Data('msg-error-noTrigger');
     }
     $actionTypeData = $thisActionType->getDbTable()->find($triggerActionId);
     if (is_null($actionTypeData)) {
         throw new Ot_Exception_Data('Data not found for this trigger action');
     }
     if ($this->_request->isPost()) {
         $dba = $action->getAdapter();
         $dba->beginTransaction();
         $data = array('name' => 'Copy of ' . $thisTriggerAction->name, 'actionKey' => $thisTriggerAction->actionKey, 'eventKey' => $thisTriggerAction->eventKey);
         try {
             $triggerActionId = $action->insert($data);
             $actionTypeData = $actionTypeData->toArray();
             $actionTypeData['triggerActionId'] = $triggerActionId;
             $thisActionType->getDbTable()->insert($actionTypeData);
         } catch (Exception $e) {
             $dba->rollback();
             throw $e;
         }
         $dba->commit();
         $logOptions = array('attributeName' => 'triggerActionId', 'attributeId' => $triggerActionId);
         $this->_helper->log(Zend_Log::INFO, 'Trigger Action cloned', $logOptions);
         $this->_helper->messenger->addSuccess($this->view->translate('msg-info-triggerCloned', array('clonedTriggerName' => $data['name'])));
         $this->_helper->redirector->gotoRoute(array('controller' => 'trigger', 'action' => 'edit', 'triggerActionId' => $triggerActionId), 'ot', true);
     } else {
         throw new Ot_Exception_Access('You are not allowed to access this method directly');
     }
 }