コード例 #1
0
 public function updateDetails()
 {
     if (Session::has('collId')) {
         $cId = Session::get('collId');
         $tmp = Participant::where('cId', $cId);
         $phone = Input::get('pPhone');
         $destination = getcwd() . "\\public\\img\\participants\\";
         if ($tmp) {
             $tmp->delete();
         }
         foreach (Input::get('pName') as $key => $name) {
             if (strlen($name) > 0) {
                 $p = new Participant();
                 $p->cId = $cId;
                 $p->pid = $key + 1;
                 $p->name = $name;
                 if (strlen($phone[$key]) > 0) {
                     $p->phone = $phone[$key];
                 }
                 $p->save();
             }
         }
         for ($i = 0; $i < sizeof(Input::file('image')); $i++) {
             if (Input::hasFile('image')) {
                 $file = Input::file('image');
                 $filename = "myfile" . $i . "." . $file[$i]->getClientOriginalExtension();
                 $flag = $file[$i]->move($destination, $filename);
             }
         }
         return Redirect::to('member');
     }
     return Redirect::to('reg');
 }
コード例 #2
0
 /**
  * Simple function to create a participant associated with this registration
  *
  * @param mixed $data
  *
  * @return Participant
  */
 public function createParticipant($data)
 {
     $participant = new Participant($this->client, $data, $this->event, $this);
     $this->participants[] = $participant;
     $participant->create();
     return $participant;
 }
コード例 #3
0
 public function run()
 {
     $participants = DB::table('event_participant')->get();
     foreach ($participants as $participant) {
         $player = Player::find($participant->player_id);
         $user = User::find($participant->user_id);
         $event = Evento::find($participant->event_id);
         $payment = Payment::find($participant->payment_id);
         $uuid = Uuid::generate();
         $new = new Participant();
         $new->id = $uuid;
         $new->firstname = $player->firstname;
         $new->lastname = $player->lastname;
         $new->due = $event->getOriginal('fee');
         $new->early_due = $event->getOriginal('early_fee');
         $new->early_due_deadline = $event->early_deadline;
         $new->method = 'full';
         $new->plan_id = Null;
         $new->player_id = $player->id;
         $new->event_id = $participant->event_id;
         $new->accepted_on = $participant->created_at;
         $new->accepted_by = $user->profile->firstname . " " . $user->profile->lastname;
         $new->accepted_user = $participant->user_id;
         $new->status = 1;
         $new->created_at = $participant->created_at;
         $new->updated_at = $participant->updated_at;
         $new->save();
         $update = Item::where('payment_id', '=', $payment->id)->firstOrFail();
         $update->participant_id = $uuid;
         $update->save();
     }
 }
コード例 #4
0
 public function updateDetails()
 {
     if (Session::has('sense')) {
         $cId = Session::get('sense')[1];
         $tmp = Participant::where('cId', $cId);
         $phone = Input::get('pPhone');
         if ($tmp) {
             $tmp->delete();
         }
         foreach (Input::get('pName') as $key => $name) {
             if (strlen($name) > 0) {
                 $p = new Participant();
                 $p->cId = $cId;
                 $p->pid = $key + 1;
                 $p->name = $name;
                 if (strlen($phone[$key]) > 0) {
                     $p->phone = $phone[$key];
                 }
                 $p->save();
             }
         }
         return Redirect::to('member/coll');
     }
     return Redirect::to('reg');
 }
コード例 #5
0
ファイル: function.part.php プロジェクト: Maharaja1/drdata
/**
 * get data for a participant and create a smarty $part variable
 */
function smarty_function_part($params, &$smarty)
{
    if (!Check::digits($params['part_id'], $empty = false)) {
        return;
    }
    $p = new Participant();
    $smarty->assign('part', $p->getone($params['part_id']));
}
コード例 #6
0
 /**
  * Check if a participant can be found within the list.
  * 
  * @param \model\Participant $participant The needle to look for.
  * 
  * @return Boolean
  */
 public function contains(Participant $participant)
 {
     foreach ($this->portfolioOwners as $key => $owner) {
         if ($owner->getUnique() == $participant->getUnique() && $owner->getName() == $participant->getName()) {
             return true;
         }
     }
     return false;
 }
コード例 #7
0
ファイル: student.php プロジェクト: andrejjursa/list-lms
 /**
  * Delete this student or related object.
  * If no parameters are set, this method deletes current student and all participant record related with this student.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     if (empty($object) && !is_array($object) && !empty($this->id)) {
         $participant = new Participant();
         $participant->where_related($this);
         $participant->get();
         $participant->delete_all();
     }
     parent::delete($object, $related_field);
 }
コード例 #8
0
 public function getRankOf(Participant $participant)
 {
     $ticket = $this->findOneBy(array('participant' => $participant));
     $parent_ticket = $this->findOneBy(array('participant' => $participant->getInvitedBy()));
     if ($parent_ticket != null && $ticket->getTime() > $parent_ticket->getTime()) {
         $ticket = $parent_ticket;
     }
     if ($ticket == null) {
         return -1;
     }
     return $this->createQueryBuilder('ticket')->select("count(ticket.id)")->where('ticket.time < :date')->setParameter('date', $ticket->getTime())->getQuery()->getSingleScalarResult() + 1;
 }
コード例 #9
0
ファイル: function.parts.php プロジェクト: Maharaja1/drdata
/**
 * get data for all participants in a study and create a smarty $parts variable
 */
function smarty_function_parts($params, &$smarty)
{
    if (!Check::digits($params['study_id'], $empty = false)) {
        return;
    }
    if ($params['all']) {
        $active = null;
    } else {
        $active = 1;
    }
    $p = new Participant();
    $smarty->assign('parts', $p->studyparts($_SESSION['user']['researcher_id'], $params['study_id'], $active));
}
コード例 #10
0
 public function add(Participant $participant)
 {
     $db = $this->connection();
     $sql = "INSERT INTO {$this->dbTable} (" . self::$key . ", " . self::$name . ") VALUES (?, ?)";
     $params = array($participant->getUnique(), $participant->getName());
     $query = $db->prepare($sql);
     $query->execute($params);
     foreach ($participant->getProjects()->toArray() as $project) {
         $sql = "INSERT INTO " . self::$projectTable . " (" . self::$key . ", " . self::$name . ", participantUnique) VALUES (?, ?, ?)";
         $query = $db->prepare($sql);
         $query->execute(array($project->getUnique(), $project->getName(), $participant->getUnique()));
     }
 }
コード例 #11
0
ファイル: phone-controller.php プロジェクト: Maharaja1/drdata
 function validateLogin()
 {
     if (!Check::isemail($email = $_REQUEST['email'])) {
         return "ERROR: invalid email!";
     }
     if (!Check::ismd5($password = $_REQUEST['password'])) {
         return "ERROR: bad password hash!";
     }
     $p = new Participant();
     if ($p->enrolled($email, $password)) {
         return "OK";
     }
     return "ERROR: participant {$email} not found";
 }
コード例 #12
0
function list_import_prepare()
{
    $CI =& get_instance();
    $periods = new Period();
    $periods->truncate();
    echo 'LIST periods table truncated ...' . "\n";
    $courses = new Course();
    $courses->truncate();
    echo 'LIST courses table truncated ...' . "\n";
    $groups = new Group();
    $groups->truncate();
    echo 'LIST groups table truncated ...' . "\n";
    $rooms = new Room();
    $rooms->truncate();
    echo 'LIST rooms table truncated ...' . "\n";
    $participants = new Participant();
    $participants->truncate();
    echo 'LIST participants table truncated ...' . "\n";
    $CI->db->simple_query('TRUNCATE TABLE `course_task_set_type_rel`');
    echo 'LIST course_task_set_type_rel table truncated ...' . "\n";
    $categories = new Category();
    $categories->truncate();
    echo 'LIST categories table truncated ...' . "\n";
    $tasks = new Task();
    $tasks->truncate();
    $CI->lang->delete_overlays('tasks');
    unlink_recursive('private/uploads/task_files/', FALSE);
    unlink_recursive('private/uploads/unit_tests/', FALSE);
    echo 'LIST tasks table truncated ...' . "\n";
    $CI->db->simple_query('TRUNCATE TABLE `task_category_rel`');
    echo 'LIST task_category_rel table truncated ...' . "\n";
    $task_set_types = new Task_set_type();
    $task_set_types->truncate();
    echo 'LIST task_set_types table truncated ...' . "\n";
    $task_sets = new Task_set();
    $task_sets->truncate();
    $CI->lang->delete_overlays('task_sets');
    echo 'LIST task_sets table truncated ...' . "\n";
    $comments = new Comment();
    $comments->truncate();
    echo 'LIST comments table truncated ...' . "\n";
    $solutions = new Solution();
    $solutions->truncate();
    unlink_recursive('private/uploads/solutions/', FALSE);
    echo 'LIST solutions table truncated ...' . "\n";
    $CI->db->simple_query('TRUNCATE TABLE `task_task_set_rel`');
    echo 'LIST task_task_set_rel table truncated ...' . "\n";
}
コード例 #13
0
ファイル: home.php プロジェクト: SwiftDeal/fbfunapp
 /**
  * @before _secure
  */
 public function profile()
 {
     $this->seo(array("title" => "Profile", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $participants = Participant::all(array("user_id = ?" => $this->user->id), array("campaign_id", "id", "created"));
     $view->set("participants", $participants);
 }
 public static function destroy($id)
 {
     self::check_admin_logged_in();
     $participant = Participant::find($id);
     Participant::delete($id);
     Participant::nullify_and_update_competition_standings($participant->competition_id);
     Redirect::to('/competition/' . $participant->competition_id . '/participants', array('message' => 'Kilpailija ' . $participant->competitor_name . ' poistettiin onnistuneesti kilpailusta ' . $participant->competition_name));
 }
コード例 #15
0
ファイル: Player.php プロジェクト: TimDN/Turnering
 function __construct($playerId, $playerFirstName, $playerSurName, $playerEmail, $participantId, $participantNickName)
 {
     parent::__construct($participantId, $participantNickName);
     $this->playerId = $playerId;
     $this->playerFirstName = $playerFirstName;
     $this->playerSurName = $playerSurName;
     $this->playerEmail = $playerEmail;
 }
コード例 #16
0
ファイル: Compare.php プロジェクト: ngchie/system
 protected function loadFiles($billrun_key, $account_id)
 {
     $source_pattern = $this->source->getInvoicePathPattern($billrun_key, $account_id);
     $source_filename = $this->getFilePathByPattern($this->source->xmls_path, $source_pattern);
     $this->source->current_account_id = $account_id;
     $this->source->loadFile($source_filename);
     $target_pattern = $this->target->getInvoicePathPattern($billrun_key, $account_id);
     $target_filename = $this->getFilePathByPattern($this->target->xmls_path, $target_pattern);
     $this->target->current_account_id = $account_id;
     $this->target->loadFile($target_filename);
 }
コード例 #17
0
ファイル: Event.php プロジェクト: riaf/jp.rhaco-users.kaigi
 function isActive($db)
 {
     if ($this->private) {
         return ExceptionTrigger::raise(new GenericException('このイベントに参加することは出来ません'));
     }
     if ($this->periodDate < time()) {
         return ExceptionTrigger::raise(new GenericException('参加登録期限が過ぎています'));
     }
     if ($db->count(new Participant(), new C(Q::eq(Participant::columnEvent(), $this->id))) >= $this->maxParticipant) {
         return ExceptionTrigger::raise(new GenericException('参加登録可能人数を超えています'));
     }
     return true;
 }
コード例 #18
0
ファイル: Messageable.php プロジェクト: spetross/ugvoice
 /**
  * Returns all threads with new messages
  *
  * @return array
  */
 public function threadsWithNewMessages()
 {
     $threadsWithNewMessages = [];
     $participants = Participant::where('user_id', $this->id)->lists('last_read', 'thread_id');
     if ($participants) {
         $threads = Thread::whereIn('id', array_keys($participants))->get();
         foreach ($threads as $thread) {
             if ($thread->updated_at > $participants[$thread->id]) {
                 $threadsWithNewMessages[] = $thread->id;
             }
         }
     }
     return $threadsWithNewMessages;
 }
 public static function update($id)
 {
     self::check_admin_logged_in();
     $attributes = self::get_attributes();
     $attributes['id'] = $id;
     $competition = new Competition($attributes);
     $errors = $competition->errors();
     if (count($errors) > 0) {
         View::make('competition/edit.html', array('errors' => $errors, 'attributes' => $attributes));
     } else {
         $competition->update();
         Participant::nullify_and_update_competition_standings($id);
         Redirect::to('/competition/' . $competition->id, array('message' => 'Kilpailua muokattu onnistuneesti!'));
     }
 }
コード例 #20
0
 /**
  * 更新请求
  *
  * @param Request $request
  * @param int $id
  * @return void
  */
 public function update(Request $request, $id)
 {
     // 验证
     $this->validate($request, ['topic' => 'string', 'participants' => 'string', 'state' => 'required|in:1,-1', 'reply_message' => 'required|string']);
     $log = Comment::find($id);
     // 更新
     DB::transaction(function () use($request, $log) {
         if (Comment::STATUS['ENABLE'] == $request->state) {
             // 参与人
             $participantIds = [];
             $participantNames = Participant::filterParticipantNames($request->participants);
             if (!empty($participantNames)) {
                 foreach ($participantNames as $name) {
                     $participant = Participant::firstOrCreate(['name' => $name]);
                     $participant->increment('counts', 1);
                     $participantIds[] = $participant->id;
                 }
             }
             // 节目
             $program = Program::where('date', date('Y-m-d', strtotime($log->metas->thread_key)))->first();
             $topic = Program::filterTopic($request->topic);
             if (!empty($topic)) {
                 $program->update(['topic' => $topic]);
             }
             if (!empty($participantIds)) {
                 $program->participants()->sync($participantIds);
             }
         }
         // 刷新首页文件缓存
         Cache::forget(Program::INDEX_CACHE_KEY);
         // 刷新贡献记录页文件缓存
         Cache::forget(Comment::CONTRIBUTION_CACHE_KEY);
         // 记录日志
         Comment::where('id', $log->id)->update(['ext_is_agree' => $request->state]);
     });
     // 回复评论
     $state = Comment::replyPost($request->reply_message, $log->metas->thread_id, $log->metas->post_id, $log->metas->author_email);
     // 跳转
     $status = ['status' => $state ? 'success' : 'error', 'message' => $state ? '审核成功~' : '审核成功,回复失败'];
     return Redirect::to($request->_redirect_url)->with($status['status'], $status['message']);
 }
コード例 #21
0
ファイル: Import.php プロジェクト: popfeng/zao
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // 获取文本路径
     $path = $this->argument('path');
     if (!is_file($path)) {
         return $this->error("Invalid file path {$path}.");
     }
     // 解析数据
     $list = self::decodeText($path);
     // 插入数据
     foreach ($list as $group) {
         DB::transaction(function () use(&$group) {
             // 插入声音记录
             self::insertAudios($group);
             // 插入参与人记录
             $data = $group['all'] ?? end($group);
             $participantIds = [];
             $participantNames = Participant::filterParticipantNames($data['participant']);
             foreach ($participantNames as $name) {
                 $participant = Participant::firstOrCreate(['name' => $name]);
                 $participant->increment('counts', 1);
                 $participantIds[] = $participant->id;
             }
             // 插入节目记录
             $topic = Program::filterTopic($data['topic']);
             if (empty($group['all'])) {
                 if (in_array(mb_substr($topic, -1), ['a', 'b', 'c'])) {
                     $topic = mb_substr($topic, 0, -1);
                 }
             }
             $program = Program::firstOrCreate(['date' => $data['date'], 'topic' => $topic, 'state' => Program::STATE_ENABLE]);
             if (!empty($participantIds)) {
                 $program->participants()->sync($participantIds);
             }
             // 输出日期
             $this->info(sprintf("%s\t%s", $data['date'], $topic));
         });
     }
 }
コード例 #22
0
 public function event($id)
 {
     //add security to avoid stealing of information
     $user = Auth::user();
     Excel::create('roster', function ($excel) use($id) {
         $excel->sheet('Sheetname', function ($sheet) use($id) {
             $event = Evento::find($id);
             $team = array();
             if ($event->children->count() > 0) {
                 foreach ($event->children as $e) {
                     foreach ($e->participants as $member) {
                         $team[] = $member;
                     }
                 }
             } else {
                 $team = Participant::where('event_id', '=', $id)->with('event')->get();
             }
             $sheet->setOrientation('landscape');
             $sheet->loadView('export.lacrosse.roster', ['members' => $team]);
         });
     })->download('xlsx');
 }
コード例 #23
0
ファイル: channel.php プロジェクト: rakesh-mohanta/Sunrise
function channel_server_start()
{
    $db = sr_pdo();
    $result = array();
    try {
        $room_list = Room::fetchAll();
        foreach ($room_list as $room) {
            channel_destroyed_log($room);
        }
        $participant_list = Participant::fetchAll();
        foreach ($participant_list as $p) {
            channel_client_disconnected_log($p);
        }
        Room::delete_all($db);
        Participant::delete_all($db);
        $result['result'] = 0;
        echo json_encode($result);
    } catch (PDOException $e) {
        $result['result'] = 1;
        $result['msg'] = 'Server error. ' . $e->getMessage();
        echo json_encode($result);
    }
}
コード例 #24
0
 public function loginAction()
 {
     if (null !== $this->_participant) {
         throw new Exception("You have already passed the checkpoint. What else do you want? If you want to get in again, I don't know why, then say your goodbyes first.");
     }
     $this->view->title = "First Checkpoint";
     //First check if the form is valid...
     $_form = new LoginForm();
     if (!$_form->isValid($_POST)) {
         $this->_redirect(APPLICATION_BASEURL_INDEX . "/participant/index/error/2");
     }
     $_auth = Zend_Auth::getInstance();
     $_authAdapter = Participant::getAuthAdapter();
     $_authAdapter->setIdentity($_form->getUsername())->setCredential(sha1($_form->getPassword()));
     //That's the actual authentication operation
     $_result = $_auth->authenticate($_authAdapter);
     if ($_result->isValid()) {
         $this->view->loggedIn = true;
         $this->_redirect(APPLICATION_BASEURL_INDEX . "/index");
     } else {
         $this->_redirect(APPLICATION_BASEURL_INDEX . "/participant/index/error/1");
     }
 }
コード例 #25
0
 /**
  * Display a listing of the resource.
  * GET /player
  *
  * @return Response
  */
 public function index()
 {
     $user = Auth::user();
     $title = 'League Together - Club';
     $players = $user->players;
     $invites = [];
     //get player from follower
     foreach ($players as $player) {
         $member = Member::where('player_id', '=', $player->id)->where('accepted_on', '=', null)->where('declined_on', '=', null)->get();
         $participant = Participant::where('player_id', '=', $player->id)->where('accepted_on', '=', null)->where('declined_on', '=', null)->get();
         if ($member) {
             foreach ($member as $data) {
                 $invites[] = $data;
             }
         }
         if ($participant) {
             foreach ($participant as $data) {
                 $invites[] = $data;
             }
         }
     }
     return View::make('app.account.player.index')->with('page_title', $title)->with('players', $user->players)->with('invites', $invites)->withUser($user);
 }
コード例 #26
0
 /**
  * FixEventLevel() method (Setting ',' values), resolveDefaults(assinging value to array) method
  */
 public function testfixEventLevel()
 {
     $paramsSet['title'] = 'Price Set';
     $paramsSet['name'] = CRM_Utils_String::titleToVar('Price Set');
     $paramsSet['is_active'] = FALSE;
     $paramsSet['extends'] = 1;
     $priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
     //Checking for priceset added in the table.
     $this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceset->id, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
     $paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'Text', 'price' => 10, 'option_label' => array('1' => 'Price Field'), 'option_value' => array('1' => 10), 'option_name' => array('1' => 10), 'option_weight' => array('1' => 1), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1);
     $ids = array();
     $pricefield = CRM_Price_BAO_PriceField::create($paramsField, $ids);
     //Checking for priceset added in the table.
     $this->assertDBCompareValue('CRM_Price_BAO_PriceField', $pricefield->id, 'label', 'id', $paramsField['label'], 'Check DB for created pricefield');
     $eventId = $this->_eventId;
     $participantParams = array('send_receipt' => 1, 'is_test' => 0, 'is_pay_later' => 0, 'event_id' => $eventId, 'register_date' => date('Y-m-d') . " 00:00:00", 'role_id' => 1, 'status_id' => 1, 'source' => 'Event_' . $eventId, 'contact_id' => $this->_contactId, 'note' => 'Note added for Event_' . $eventId, 'fee_level' => 'Price_Field - 55');
     $participant = CRM_Event_BAO_Participant::add($participantParams);
     //Checking for participant added in the table.
     $this->assertDBCompareValue('CRM_Event_BAO_Participant', $this->_contactId, 'id', 'contact_id', $participant->id, 'Check DB for created participant');
     $values = array();
     $ids = array();
     $params = array('id' => $participant->id);
     CRM_Event_BAO_Participant::getValues($params, $values, $ids);
     $this->assertNotEquals(count($values), 0, 'Checking for empty array.');
     CRM_Event_BAO_Participant::resolveDefaults($values[$participant->id]);
     if ($values[$participant->id]['fee_level']) {
         CRM_Event_BAO_Participant::fixEventLevel($values[$participant->id]['fee_level']);
     }
     $deletePricefield = CRM_Price_BAO_PriceField::deleteField($pricefield->id);
     $this->assertDBNull('CRM_Price_BAO_PriceField', $pricefield->id, 'name', 'id', 'Check DB for non-existence of Price Field.');
     $deletePriceset = CRM_Price_BAO_PriceSet::deleteSet($priceset->id);
     $this->assertDBNull('CRM_Price_BAO_PriceSet', $priceset->id, 'title', 'id', 'Check DB for non-existence of Price Set.');
     Participant::delete($participant->id);
     Contact::delete($this->_contactId);
     Event::delete($eventId);
 }
コード例 #27
0
 public function createAction()
 {
     $expId = intval($this->getRequest()->getParam(Expertise::COL_ID));
     $keyId = intval($this->getRequest()->getParam(KeyTable::COL_ID));
     $expTable = new Expertise();
     $expRow = $expTable->find($expId);
     $keyTable = new KeyTable();
     $keyRow = $keyTable->find($keyId);
     if ($keyRow->count() != 0 || $expRow->count() != 0) {
         $keyArray = $keyRow->toArray();
         $expArray = $expRow->toArray();
         // create CE row
         $ceTable = new CalibrationExercise();
         $ceName = $expArray[0][Expertise::COL_SPECIES] . ' / ' . AuthQuery::getUserName();
         //TODO \r in der Datenbank
         $ceDescription = 'Area: ' . $expArray[0][Expertise::COL_AREA] . '\\r' . 'Subject: ' . $expArray[0][Expertise::COL_SUBJECT] . '\\r' . 'KeyName: ' . $keyArray[0][KeyTable::COL_NAME];
         $ceData = array(CalibrationExercise::COL_NAME => $ceName, CalibrationExercise::COL_DESCRIPTION => $ceDescription, CalibrationExercise::COL_KEY_TABLE_ID => $keyArray[0][KeyTable::COL_ID], CalibrationExercise::COL_EXPERTISE_ID => $expArray[0][Expertise::COL_ID], CalibrationExercise::COL_COMPAREABLE => 1, CalibrationExercise::COL_IS_STOPPED => 0, CalibrationExercise::COL_TRAINING => 1);
         $ceId = $ceTable->insert($ceData);
         // create participant row
         $partTable = new Participant();
         $partData = array(Participant::COL_CE_ID => $ceId, Participant::COL_USER_ID => AuthQuery::getUserId(), Participant::COL_NUMBER => 1);
         $partId = $partTable->insert($partData);
         // add all possible shown attributes
         $dbAdapter = $ceTable->getAdapter();
         $selectAttr = $dbAdapter->select();
         $selectAttr->from(AttributeDescriptor::TABLE_NAME);
         $selectAttr->orWhere(AttributeDescriptor::COL_GROUP . '=?', 'fish');
         $selectAttr->orWhere(AttributeDescriptor::COL_GROUP . '=?', 'image');
         $attrArray = $dbAdapter->fetchAll($selectAttr);
         $ceHasAttrTable = new CeHasAttributeDescriptor();
         foreach ($attrArray as $attr) {
             $attrData = array(CeHasAttributeDescriptor::COL_ATDE_ID => $attr[AttributeDescriptor::COL_ID], CeHasAttributeDescriptor::COL_CAEX_ID => $ceId);
             $ceHasAttrTable->insert($attrData);
         }
         //get images for exp/key
         $refQuery = new Default_ReferenceQuery();
         $images = $refQuery->getImages($expId, $keyId);
         // create imageset
         //			$selectImages = $dbAdapter->select();
         //			$imagesArray = $dbAdapter->fetchAll($selectImages);
         $imageSetTable = new CeHasImage();
         foreach ($images as $image) {
             $data = array(CeHasImage::COL_IMAGE_ID => $image, CeHasImage::COL_CALIBRATION_EXERCISE_ID => $ceId);
             $imageSetTable->insert($data);
         }
         //$this->render('form');
         $Redirect = new Zend_Controller_Action_Helper_Redirector();
         $Redirect->setGotoSimple('index', 'make', 'annotation', array(CalibrationExercise::COL_ID => $ceId));
     } else {
         throw new Zend_Controller_Exception('Error at craeting a new training Calibration Exercise.', 505);
     }
 }
コード例 #28
0
     date_default_timezone_set('America/Chicago');
     include "../include/dbconnopen.php";
     $link_id_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['link_id']);
     $drop_from_program = "UPDATE Participants_Programs SET Date_Dropped='" . date('Y-m-d') . "' WHERE Participant_Program_ID='" . $link_id_sqlsafe . "'";
     echo $drop_from_program;
     mysqli_query($cnnEnlace, $drop_from_program);
     include "../include/dbconnclose.php";
 } else {
     include "../include/dbconnopen.php";
     $participant_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['participant']);
     $program_id_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['program_id']);
     $add_person_to_program = "INSERT INTO Participants_Programs (Participant_ID, Program_ID) VALUES ('{$participant_sqlsafe}', '{$program_id_sqlsafe}')";
     mysqli_query($cnnEnlace, $add_person_to_program);
     include "../include/dbconnclose.php";
     // Construct a participant object
     $participant = new Participant();
     $participant->load_with_participant_id($participant_sqlsafe);
     // Find the participants surveys are impact surveys from the last 6 months.
     $assessments = $participant->find_previous_surveys(6, Assessment::IMPACT_TYPE);
     print_r($assessments);
     if ($assessments) {
         // A survey exists, we should now duplicate the newest (first in array)
         $assessment = $assessments[0];
         // Removing the primary key will cause Assessment to create a new one on Assessment->save()
         $assessment->assessment_id = null;
         // Change the type and session
         $assessment->pre_post = Assessment::INTAKE_TYPE;
         $assessment->session_id = $program_id_sqlsafe;
         // Save this back to the database
         $assessment->save();
     }
コード例 #29
0
 /**
  * {@inheritdoc}
  */
 public function getConsistency($ignore_first_lap = true)
 {
     // There is cache
     if ($this->cache_consistency[$ignore_first_lap] !== null) {
         return $this->cache_consistency[$ignore_first_lap];
     }
     // Return consistency
     return $this->cache_consistency[$ignore_first_lap] = parent::getConsistency($ignore_first_lap);
 }
コード例 #30
0
ファイル: Participant.php プロジェクト: kochichi/LimeSurvey
 function copyToCentral($surveyid, $aAttributesToBeCreated, $aMapped, $overwriteauto = false, $overwriteman = false, $createautomap = true)
 {
     $tokenid = Yii::app()->session['participantid'];
     //List of token_id's to add to participants table
     $duplicate = 0;
     $sucessfull = 0;
     $writearray = array();
     $attid = array();
     //Will store the CPDB attribute_id of new or existing attributes keyed by CPDB at
     $pid = "";
     /* Grab all the existing attribute field names from the tokens table */
     $arr = Yii::app()->db->createCommand()->select('*')->from("{{tokens_{$surveyid}}}")->queryRow();
     if (is_array($arr)) {
         $tokenfieldnames = array_keys($arr);
         $tokenattributefieldnames = array_filter($tokenfieldnames, 'filterForAttributes');
     } else {
         $tokenattributefieldnames = array();
     }
     /* Create CPDB attributes */
     if (!empty($aAttributesToBeCreated)) {
         foreach ($aAttributesToBeCreated as $key => $value) {
             /* $key is the fieldname from the token table (ie "attribute_1")
              * $value is the 'friendly name' for the attribute (ie "Gender")
              */
             $insertnames = array('attribute_type' => 'TB', 'visible' => 'Y', 'defaultname' => $value);
             Yii::app()->db->createCommand()->insert('{{participant_attribute_names}}', $insertnames);
             $attid[$key] = $aAttributesToBeCreated[$key] = getLastInsertID('{{participant_attribute_names}}');
             /* eg $attid['attribute_1']='8372' */
             $insertnameslang = array('attribute_id' => $attid[$key], 'attribute_name' => urldecode($value), 'lang' => Yii::app()->session['adminlang']);
             Yii::app()->db->createCommand()->insert('{{participant_attribute_names_lang}}', $insertnameslang);
         }
     }
     /* Add the participants to the CPDB = Iterate through each $tokenid and create the new CPDB id*/
     foreach ($tokenid as $key => $tid) {
         if (is_numeric($tid) && $tid != "") {
             /* Get the data for this participant from the tokens table */
             $tobeinserted = Yii::app()->db->createCommand()->select('participant_id,firstname,lastname,email,language')->where('tid = :tid')->from('{{tokens_' . intval($surveyid) . '}}')->bindParam(":tid", $tid, PDO::PARAM_INT)->queryRow();
             /* See if there are any existing CPDB entries that match on firstname,lastname and email */
             $query = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->where('firstname = :firstname AND lastname = :lastname AND email = :email')->bindParam(":firstname", $tobeinserted['firstname'], PDO::PARAM_STR)->bindParam(":lastname", $tobeinserted['lastname'], PDO::PARAM_STR)->bindParam(":email", $tobeinserted['email'], PDO::PARAM_STR)->queryAll();
             /* If there is already an existing entry, add to the duplicate count */
             if (count($query) > 0) {
                 $duplicate++;
                 if ($overwriteman == "true" && !empty($aMapped)) {
                     foreach ($aMapped as $cpdbatt => $tatt) {
                         Participant::model()->updateAttributeValueToken($surveyid, $query[0]['participant_id'], $cpdbatt, $tatt);
                     }
                 }
             } else {
                 /* Create entry in participants table */
                 $black = !empty($tobeinserted['blacklisted']) ? $tobeinserted['blacklisted'] : 'N';
                 $pid = !empty($tobeinserted['participant_id']) ? $tobeinserted['participant_id'] : $this->gen_uuid();
                 $writearray = array('participant_id' => $pid, 'firstname' => $tobeinserted['firstname'], 'lastname' => $tobeinserted['lastname'], 'email' => $tobeinserted['email'], 'language' => $tobeinserted['language'], 'blacklisted' => $black, 'owner_uid' => Yii::app()->session['loginID'], 'created_by' => Yii::app()->session['loginID'], 'created' => date('Y-m-d H:i:s', time()));
                 Yii::app()->db->createCommand()->insert('{{participants}}', $writearray);
                 //Update token table and insert the new UUID
                 $data = array("participant_id" => $pid);
                 Yii::app()->db->createCommand()->update('{{tokens_' . intval($surveyid) . '}}', $data, "tid = {$tid}");
                 /* Now add any new attribute values */
                 if (!empty($aAttributesToBeCreated)) {
                     foreach ($aAttributesToBeCreated as $key => $value) {
                         Participant::model()->updateAttributeValueToken($surveyid, $pid, $attid[$key], $key);
                     }
                 }
                 /* Now add mapped attribute values */
                 if (!empty($aMapped)) {
                     foreach ($aMapped as $cpdbatt => $tatt) {
                         Participant::model()->updateAttributeValueToken($surveyid, $pid, $cpdbatt, $tatt);
                     }
                 }
                 $sucessfull++;
                 /* Create a survey_link */
                 $data = array('participant_id' => $pid, 'token_id' => $tid, 'survey_id' => $surveyid, 'date_created' => date('Y-m-d H:i:s', time()));
                 Yii::app()->db->createCommand()->insert('{{survey_links}}', $data);
             }
         }
     }
     if ($createautomap == "true") {
         $aAttributes = Survey::model()->findByPk($surveyid)->tokenattributes;
         if (!empty($aAttributesToBeCreated)) {
             // If automapping is enabled then update the token field properties with the mapped CPDB field ID
             foreach ($aAttributesToBeCreated as $tatt => $cpdbatt) {
                 $aAttributes[$tatt]['cpdbmap'] = $cpdbatt;
             }
             Yii::app()->db->createCommand()->update('{{surveys}}', array("attributedescriptions" => json_encode($aAttributes)), 'sid = ' . $surveyid);
         }
         if (!empty($aMapped)) {
             foreach ($aMapped as $cpdbatt => $tatt) {
                 // Update the attributedescriptions so future mapping can be done automatically
                 $aAttributes[$tatt]['cpdbmap'] = $cpdbatt;
             }
             Yii::app()->db->createCommand()->update('{{surveys}}', array("attributedescriptions" => json_encode($aAttributes)), 'sid = ' . $surveyid);
         }
     }
     $returndata = array('success' => $sucessfull, 'duplicate' => $duplicate, 'overwriteauto' => $overwriteauto, 'overwriteman' => $overwriteman);
     return $returndata;
 }