コード例 #1
0
ファイル: Messages.php プロジェクト: kemosabhay/Lightning
 public function __construct()
 {
     parent::__construct();
     $action = Request::get('action');
     if ($action == 'edit' || $action == 'new') {
         JS::startup('
             lightning.admin.messageEditor.checkVars();
             $("#add_message_criteria_button").click(lightning.admin.messageEditor.checkVars);
         ');
     }
     $this->post_actions['after_post'] = function () {
         $db = Database::getInstance();
         // Find all the criteria added to this message
         $criteria_list = $db->select(array('from' => 'message_message_criteria', 'join' => array('JOIN', 'message_criteria', 'USING (message_criteria_id)')), array('message_id' => $this->id));
         // See if any variables have been set.
         foreach ($criteria_list as $c) {
             // If the criteria requires variables.
             if (!empty($c['variables'])) {
                 // See what variables are required.
                 $vars = explode(',', $c['variables']);
                 $var_data = array();
                 foreach ($vars as $v) {
                     $var_data[$v] = Request::post('var_' . $c['message_criteria_id'] . '_' . $v);
                 }
                 $db->update('message_message_criteria', array('field_values' => json_encode($var_data)), array('message_id' => Request::post('id', 'int'), 'message_criteria_id' => $c['message_criteria_id']));
             }
         }
     };
 }
コード例 #2
0
ファイル: ListUsers.php プロジェクト: kemosabhay/Lightning
 public function __construct()
 {
     ClientUser::requireAdmin();
     $list_id = Request::get('list', 'int');
     if ($list_id === 0) {
         Template::getInstance()->set('title', 'Users not on any mailing list.');
         $this->accessTableCondition = array('message_list_id' => array('IS NULL'));
     } elseif ($list_id > 0) {
         $list = Database::getInstance()->selectField('name', 'message_list', array('message_list_id' => $list_id));
         Template::getInstance()->set('title', "Users on list {$list}.");
         $this->accessTableCondition = array('message_list_id' => $list_id);
     } else {
         Template::getInstance()->set('title', 'All users on all lists.');
     }
     parent::__construct();
 }