コード例 #1
0
ファイル: Action.php プロジェクト: shelsonjava/datawrapper
 public static function logAction($user, $key, $details = null)
 {
     $action = new Action();
     $action->setUser($user);
     $action->setKey($key);
     if (!empty($details)) {
         $action->setDetails($details);
     }
     $action->setActionTime(time());
     $action->save();
 }
コード例 #2
0
 public function createDefaultActions($post_id, $p_type)
 {
     for ($i = 1; $i <= ACTIONS_COUNT; $i++) {
         $action = new Action();
         $action->user_id = Session::get('current_user');
         $action->a_type = $i;
         $action->post_id = $post_id;
         $action->p_type = $p_type;
         $action->save();
     }
 }
コード例 #3
0
 public static function initActions()
 {
     $actions = (include Yii::app()->basePath . '/config-dist/actions.php');
     foreach ($actions as $k => $v) {
         $action = new Action();
         $ret = $action->find('aname=:name', array(':name' => $v['aname']));
         if (empty($ret)) {
             $action->aname = $v['aname'];
             $action->route = $v['route'];
             $action->is_menu = $v['is_menu'];
             $action->save();
         }
     }
 }
コード例 #4
0
ファイル: Action.php プロジェクト: Halfnhav4/datawrapper
 public static function logAction($user, $key, $details = null)
 {
     $action = new Action();
     $action->setUser($user);
     $action->setKey($key);
     if (!empty($details)) {
         if (!is_numeric($details) && !is_string($details)) {
             $details = json_encode($details);
         }
         $action->setDetails($details);
     }
     $action->setActionTime(time());
     $action->save();
 }
コード例 #5
0
ファイル: AddCourse.php プロジェクト: bennyty/suggestr
 public function process($get, $post)
 {
     if (!isset($post['course_id']) || !is_numeric($post['course_id']) || !isset($_COOKIE['sessionId']) || !is_numeric($_COOKIE['sessionId'])) {
         $this->failureReason = 'Sorry, there was an error.';
         return false;
     }
     $query = new Query('action');
     // Select all the courses that are in this user's session and have this course id
     $result = $query->select('*', array(array('course_id', '=', $post['course_id']), array('session_id', '=', $_COOKIE['sessionId'])), '', 1);
     if (count($result) != 0) {
         // Abort because this course is already in the user's model
         $this->failureReason = 'Sorry, there was an error';
         return false;
     }
     // Now add this course to the user's model
     $action = new Action();
     $action->set('course_id', $post['course_id']);
     $action->set('session_id', $_COOKIE['sessionId']);
     $action->save();
     return true;
 }
コード例 #6
0
 public function run()
 {
     $key_door = new Action();
     $key_door->item_1 = 'key';
     $key_door->item_2 = 'door';
     $key_door->location = 2;
     $key_door->result = 'The door unlocks and swings open. You can now go east into the tower.';
     $key_door->save();
     $lantern_hay = new Action();
     $lantern_hay->item_1 = 'lantern';
     $lantern_hay->item_2 = 'hay';
     $lantern_hay->location = 7;
     $lantern_hay->result = 'You stick some hay into the lantern. As it catches fire you drop it all on the rest of the hay, the fire is spreading quickly and you can hear the gaurds coming to invesigate. You should sneak off while they are disracted.';
     $lantern_hay->save();
     $wine_guard = new Action();
     $wine_guard->item_1 = 'wine';
     $wine_guard->item_2 = 'guard';
     $wine_guard->location = 20;
     $wine_guard->result = 'You quietly place the wine against the wall where the gaurds can see it. After a little they pick it up, and being bored, start to drink. A few moments later they sucumb to their fatigue and fall into a drunken stupor';
     $wine_guard->save();
 }
コード例 #7
0
$oldActionNames = array();
foreach ($oldActions as $oldAction) {
    $name = $oldAction->get('name');
    if (!in_array($name, $actions)) {
        $oldAction->delete();
        echo "Deleting {$name}<br />\n";
    } else {
        $oldActionNames[] = $name;
    }
}
foreach ($actions as $action) {
    if (!in_array($action, $oldActionNames)) {
        echo "Adding {$action}<br />\n";
        $new = new Action();
        $new->set('name', $action);
        $new->save();
    }
}
$actions = Action::searchForAll();
$statuses = Status::searchForAll();
$rights = Right::SearchForAll();
$listRights = array();
foreach ($actions as $action) {
    foreach ($statuses as $status) {
        $listRights[] = $action->get('id') . '.' . $status->get('id');
    }
}
$oldrights = array();
foreach ($rights as $right) {
    $actionId = $right->get('actionId');
    $statusId = $right->get('statusId');
コード例 #8
0
ファイル: edit_action.php プロジェクト: nigeldgreen/tasksapp
<?php

$actionID = $this->id();
Command::captureUrl();
if (TasksappValidator::checkInteger($actionID)) {
    $db = Database::getInstance();
    $inputArray = $db->getActionByActionID($actionID);
    $action = $inputArray[0];
} else {
    $action = new Action($_POST);
    if ($action->verifyActionData()) {
        $action->save();
        header("Location: " . Command::retrieveUrl());
        exit;
    }
}
$projectsArray = Command::getProjectList($action->client_id());
include_once '../views/showEditActionForm.php';
コード例 #9
0
 public function postUpdate($group_id)
 {
     Allow::permission($this->module['group'], 'groups');
     $json_request = array('status' => FALSE, 'responseText' => '', 'responseErrorText' => '', 'redirect' => FALSE);
     if (!Request::ajax()) {
         App::abort(404);
     }
     if (!($group = Group::find($group_id))) {
         $json_request['responseText'] = 'Запрашиваемая группа не найдена!';
         return Response::json($json_request, 400);
     }
     $validation = Validator::make(Input::all(), Group::$rules_update);
     if ($validation->passes()) {
         ## Update group
         $group->name = mb_strtolower(Input::get('name'));
         $group->desc = Input::get('desc');
         $group->dashboard = Input::get('dashboard');
         $group->start_url = Input::get('start_url');
         $group->save();
         $group->touch();
         ## Update actions
         Action::where('group_id', $group_id)->delete();
         if (is_array(Input::get('actions')) && count(Input::get('actions'))) {
             foreach (Input::get('actions') as $module_name => $actions) {
                 foreach ($actions as $a => $act) {
                     $action = new Action();
                     $action->group_id = $group_id;
                     $action->module = $module_name;
                     $action->action = $act;
                     $action->status = 1;
                     $action->save();
                 }
             }
         }
         $json_request['responseText'] = 'Группа обновлена';
         #$json_request['responseText'] = print_r($group_id, 1);
         #$json_request['responseText'] = print_r($group, 1);
         #$json_request['responseText'] = print_r(Input::get('actions'), 1);
         #$json_request['responseText'] = print_r($group->actions(), 1);
         #$json_request['redirect'] = link::auth('groups');
         $json_request['status'] = TRUE;
     } else {
         $json_request['responseText'] = 'Неверно заполнены поля';
         $json_request['responseErrorText'] = implode($validation->messages()->all(), '<br />');
     }
     return Response::json($json_request, 200);
 }
コード例 #10
0
ファイル: AlbumsController.php プロジェクト: kylehagler/CHP
 public function addSample($songID)
 {
     $song = Song::find($songID);
     if ($song == null) {
         return Redirect::route('albums-home')->with('fail', "That song doesn't exist.");
     }
     if (Input::get('sample-artist') == '') {
         return Redirect::route('albums-home')->with('fail', "Please enter Artist Name.");
     }
     if (Input::get('sample-title') == '') {
         return Redirect::route('albums-home')->with('fail', "Please enter Song Title.");
     }
     $sample = new Sample();
     $sample->song_id = $songID;
     $sample->sample_artist = Input::get('sample-artist');
     $sample->sample_title = Input::get('sample-title');
     $sample->author_id = Auth::user()->id;
     $action = new Action();
     $action->song_title = $song->title;
     $action->action = "Added sample";
     $action->user_id = Auth::user()->id;
     if ($sample->save() && $action->save()) {
         return Redirect::route('albums-home')->with('success', 'The sample was added.');
     } else {
         return Redirect::route('albums-home')->with('fail', 'An error occured while saving the sample.');
     }
 }
コード例 #11
0
 public function actionEdit()
 {
     //echo "<pre>";var_dump($_REQUEST);exit;
     $action = new Action();
     $actionInfo = array();
     $label = '';
     foreach ($_REQUEST as $k => $v) {
         $_REQUEST[$k] = trim($v);
     }
     $menutype = isset($_REQUEST['menu_type']) ? intval($_REQUEST['menu_type']) : '0';
     $whichFirstMenu = isset($_REQUEST['firstmenu']) ? intval($_REQUEST['firstmenu']) : '-1';
     $menusort = isset($_REQUEST['menusort']) ? intval($_REQUEST['menusort']) : 0;
     $firstmenus = Action::model()->findAll('is_menu=1');
     if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
         // 修改
         $actionInfo = $action->find('aid=:id', array(':id' => $_REQUEST['id']));
         if (!empty($_REQUEST['modify'])) {
             $action->updateByPk($_REQUEST['id'], array('aname' => $_REQUEST['name'], 'route' => $_REQUEST['route'], 'is_menu' => $menutype, 'menusort' => $menusort, 'first_menu' => $whichFirstMenu));
             $this->redirect('/main/action/list');
         }
     } elseif (!empty($_REQUEST['name'])) {
         // 新增
         $actionInfo = $action->find('aname=:name or route=:route', array(':name' => $_REQUEST['name'], ':route' => $_REQUEST['route']));
         if (!empty($actionInfo)) {
             $this->render('edit', array('firstmenus' => $firstmenus, 'entity' => $actionInfo, 'label' => 'has_action'));
             exit;
         }
         if (!empty($_REQUEST['modify'])) {
             $action->aname = $_REQUEST['name'];
             $action->route = $_REQUEST['route'];
             $action->is_menu = $menutype;
             $action->first_menu = $whichFirstMenu;
             $action->menusort = $menusort;
             $action->save();
             $this->redirect('/main/action/list');
         }
         //echo "<pre>";var_dump($_REQUEST,$actionInfo);exit;
     }
     $this->render('edit', array('firstmenus' => $firstmenus, 'entity' => $actionInfo, 'label' => $label));
 }
コード例 #12
0
// Clear out the lookup tables.  We'll import everything from Mongo
// The mysql.sql script preloads some generic values for these tables
$zend_db->delete('resolutions');
$zend_db->delete('actions');
$result = $mongo->resolutions->find();
foreach ($result as $r) {
    $o = new Resolution();
    $o->handleUpdate($r);
    $o->save();
    echo "Resolution: {$o->getName()}\n";
}
$result = $mongo->actions->find();
foreach ($result as $r) {
    $o = new Action();
    $o->handleUpdate($r);
    $o->save();
    echo "Action: {$o->getName()}\n";
}
$result = $mongo->lookups->findOne(array('name' => 'contactMethods'));
$methods = $result['items'];
foreach ($methods as $m) {
    $o = new ContactMethod();
    $o->setName($m);
    $o->save();
    echo "ContactMethod: {$o->getName()}\n";
}
$result = $mongo->lookups->findOne(array('name' => 'types'));
$types = $result['items'];
foreach ($types as $t) {
    $o = new IssueType();
    $o->setName($t);
コード例 #13
0
ファイル: ActionController.php プロジェクト: nattaphat/cuse2
 /**
  * [saveAction description]
  * @return [type] [description]
  */
 public function saveAction()
 {
     Input::flash();
     $data = Input::all();
     $rules = array('actionname' => array('min:3', 'required'));
     // Build the custom messages array.
     $messages = array('action.min' => 'กรุณาระบุชื่อการกระทำอย่างน้อย :min ตัวอักษร.', 'action.required' => 'กรุณาระบุชื่อการกระทำ');
     $action_content = trim($data['actionname']);
     // Create a new validator instance.
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->passes()) {
         $action = new Action();
         $chk_action = $action->checkAction($action_content);
         if ($chk_action) {
             $action->action_name = $action_content;
             $action->save();
             return Redirect::route('actionshow')->with('success', 'บันทึกสำเร็จ');
         } else {
             return Redirect::route('actionadd')->with('warning', 'มีชื่อการกระทำในระบบแล้ว');
         }
     } else {
         // $errors = $validator->messages();
         return Redirect::route('actionadd')->withErrors($validator);
     }
 }