public function _new($followup = FALSE) { if (array_key_exists('followup', $this->_data)) { $followup = $this->_data['followup']; } $this->view->set('page_title', 'New CRM Activity'); // New follow-up activity if ($followup) { $this->view->set('page_title', 'New CRM Follow-up Activity'); unset($this->_data['id']); $activity = new Activity(); $activity->load($followup); $this->_data['person_id'] = $activity->person_id; $this->_data['company_id'] = $activity->company_id; $this->_data['name'] = $activity->name; $this->_data['description'] = $activity->description; $this->_data['completed'] = ''; } // Edit existing activity if (isset($this->_data['id'])) { $this->view->set('page_title', 'Edit CRM Activity'); } // New activity from opportunity if (isset($this->_data['opportunity_id'])) { $this->view->set('page_title', 'New CRM Activity'); $opportunity = DataObjectFactory::Factory('Opportunity'); $opportunity->load($this->_data['opportunity_id']); $this->_data['person_id'] = $opportunity->person_id; $this->_data['company_id'] = $opportunity->company_id; } parent::_new(); }
function logActivity($action, $body = null) { $activity = new Activity($this); $name = $this->logName(); $activity->body = "{$action} {$activity->target_class} {$activity->target_id}" . ($name ? ", \"{$name}\"" : ""); $activity->save(); }
/** * load in the Activities for the given SQL statement * * @param string $sql * @param array $params the parameters that go into the sql statement * @param String $style (optional - default 'long') may be 'short' or 'long' or 'cif' * @return ActivitySet (this) */ function load($sql, $params, $style = 'long') { global $DB; if (!isset($params)) { $params = array(); } // get records $resArray = $DB->select($sql, $params); if ($resArray !== false) { $count = count($resArray); for ($i = 0; $i < $count; $i++) { $array = $resArray[$i]; $a = new Activity(); $xml = $array['XML']; $activity = $a->load($array['ItemID'], $array['UserID'], $array['Type'], $array['ModificationDate'], $array['ChangeType'], $xml, $style); if (!$activity instanceof Error) { $this->add($a); } } $this->totalno = count($this->activities); } else { return database_error(); } return $this; }
function log($activity) { $act = new Activity(); $act->message = $activity; $act->user_id = Auth::user()->id; $act->save(); }
/** * Store to the database the given entities as entities decendent from the given * document. * * @param $document Parent document -- Must be a document entity on the database. * @param $entities List of entities to be created as decendents from the given document. * * @return multitype:string A status array containing the result status information. */ public function store($parent, $units, $type) { if (count($units) <= 0 && count($units) >= 10000) { // We will have problems processing empty files or more than 10,000 entities return ['error' => 'Unable to process files with more than 10,000 lines: ' . $nEnts . 'found']; } $activity = new \Activity(); $activity->softwareAgent_id = $this->softwareComponent->_id; $activity->save(); $entities = []; foreach ($units as $unit) { try { $entity = new Unit(); $entity->project = $parent->project; $entity->activity_id = $activity->_id; $entity->documentType = $type; $entity->parents = [$parent->_id]; $entity->content = $unit; $entity->hash = md5(serialize($entity)); $entity->save(); array_push($entities, $entity); } catch (Exception $e) { foreach ($entities as $en) { $en->forceDelete(); } throw $e; } } \Temp::truncate(); return ['success' => 'Sentences created successfully']; }
public static function boot() { parent::boot(); static::creating(function ($workerunit) { // dd($workerunit); // Inherit type, domain and format if (empty($workerunit->type) or empty($workerunit->domain) or empty($workerunit->format)) { $j = Job::where('_id', $workerunit->job_id)->first(); $workerunit->type = $j->type; $workerunit->domain = $j->domain; $workerunit->format = $j->format; } $workerunit->annotationVector = $workerunit->createAnnotationVector(); // Activity if not exists if (empty($workerunit->activity_id)) { try { $activity = new Activity(); $activity->label = "Workerunit is saved."; $activity->softwareAgent_id = $workerunit->softwareAgent_id; $activity->save(); $workerunit->activity_id = $activity->_id; Log::debug("Saving workerunit {$workerunit->_id} with activity {$workerunit->activity_id}."); } catch (Exception $e) { if ($activity) { $activity->forceDelete(); } //if($workerunit) $workerunit->forceDelete(); throw new Exception('Error saving activity for workerunit.'); } } }); }
public function update($id, $data) { $action = $this->params()->fromQuery('action'); $project = $this->find('\\User\\Entity\\Project', $id); if ($action == 1) { $project->setData(['tax' => $data['tax'], 'discount' => $data['discount']]); $project->save($this->getEntityManager()); } if ($action == 2) { $project->setData(['status' => 2]); $project->save($this->getEntityManager()); $activity = new Activity(); $activity->setData(['activityDate' => new \DateTime('NOW'), 'project' => $project, 'type' => "accept_quote", 'sender' => $this->getReference('\\User\\Entity\\User', $data['client']['id'])]); //$activity->save($this->getEntityManager()); } if ($action == 3) { $arr = []; foreach ($data['types'] as $type) { $arr[] = $type['id']; } $data['types'] = $arr; $project->setData(['tax' => $data['tax'], 'discount' => $data['discount'], 'duration' => $data['duration'], 'serviceLevel' => $data['serviceLevel'], 'types' => $data['types']]); $project->save($this->getEntityManager()); } return new JsonModel(['project' => $project->getData()]); }
function get($criteria = null) { $user = current_user(); $projects = new Project(); $activity = new Activity(); $this->projects = $projects->get(); $this->activity = $activity->get(); }
function afterFind(\Model $model, $results, $primary) { parent::afterFind($model, $results, $primary); if ($model->id) { $data = array('model' => $model->alias, 'model_id' => $model->id, 'activity_type' => 'R', 'user_id' => $model->loginUser['id']); $activity = new Activity(); $activity->save($data); } }
protected function getOldActivity($subject, $created) { $activity = new Activity(['subject_id' => $subject->getKey(), 'subject_type' => get_class($subject), 'user_id' => 1, 'name' => 'created_post']); $time = Carbon::createFromTimestamp($created)->toDateTimeString(); $activity->setCreatedAt($time); $activity->setUpdatedAt($time); $activity->save(); return $activity; }
public function actionActivity() { $model = new Activity('search'); $model->with('users'); $model->unsetAttributes(); if (isset($_GET['Activity'])) { $model->attributes = $_GET['Activity']; } $this->render('activity', array('model' => $model)); }
/** * op_activity_body_filter * * @param Activity $activity * @param boolean $is_auto_link * @return string */ function op_activity_body_filter($activity, $is_auto_link = true) { $body = $activity->getBody(); if ($activity->getTemplate()) { $config = $activity->getTable()->getTemplateConfig(); if (!isset($config[$activity->getTemplate()])) { return ''; } $params = array(); foreach ($activity->getTemplateParam() as $key => $value) { $params[$key] = $value; } $body = __($config[$activity->getTemplate()], $params); $event = sfContext::getInstance()->getEventDispatcher()->filter(new sfEvent(null, 'op_activity.template.filter_body'), $body); $body = $event->getReturnValue(); } $event = sfContext::getInstance()->getEventDispatcher()->filter(new sfEvent(null, 'op_activity.filter_body'), $body); $body = $event->getReturnValue(); if (false === strpos($body, '<a') && $activity->getUri()) { return link_to($body, $activity->getUri()); } if ($is_auto_link) { if ('mobile_frontend' === sfConfig::get('sf_app')) { return op_auto_link_text_for_mobile($body); } return op_auto_link_text($body); } return $body; }
public function pay($tid) { $trade = $this->getOne($tid); if (!empty($trade) && $trade['status'] == 'created') { $this->touch($tid, 'paid'); require_once MB_ROOT . '/source/Activity.class.php'; $a = new Activity(); $activity = $a->getOne($trade['activity']); $this->pool($trade['activity'], $activity['tag']['price']); } }
/** * Convert the raw XML into an object * * @param \SimpleXMLElement $xml * @return Activity */ public static function createFromXML(\SimpleXMLElement $xml) { $activity = new Activity(); if (isset($xml->attributes()['count'])) { $activity->setCount((int) $xml->attributes()['count']); } if (isset($xml->attributes()['type'])) { $activity->setType((string) $xml->attributes()['type']); } return $activity; }
public function pay(Order $order, Activity $activity, $lang) { $activity_data = $activity->get_activity_data(); $info = model('wt_payment_info')->get_one(array('activity_id' => $activity_data['activity_id'])); if (!$info) { $ret['r'] = 'error'; $ret['msg'] = '50004:Payment Info get failed.'; } $data = array(); $data['payment_info'] = $lang == 'en' ? $info['info_en'] : $info['info_zh']; return $this->generate_html($data); }
function social_news() { global $db; $news = array(); $actvity_obj = new Activity(); $activities = $actvity_obj->getFriendsActivities($_SESSION['member_id']); foreach ($activities as $row) { $link_title = printSocialName($row['member_id']) . ' ' . $row['title']; $news[] = array('time' => $row['created_date'], 'object' => $row, 'thumb' => 'images/home-directory_sm.png', 'link' => '<span title="' . strip_tags($link_title) . '">' . $link_title . "</span>"); } return $news; }
/** * Adds activities * * @return Redirect * @author Dan Cox */ public function addActivities($id) { $schedule = DB::find('Schedule', $id); $activity = new Activity(); $activity->setLabel(Input::get('label'))->setHours(Input::has('hours') ? Input::get('hours') : NULL)->setDay(Input::has('day') ? Input::get('day') : NULL)->setTimes(Input::has('times') ? Input::get('times') : NULL); $errors = Validator::make($activity); if (count($errors) > 0) { return Redirect::route('page.addActivities', ['id' => $id])->withInput()->withErrors($errors)->send(); } $activity->setSchedule($schedule); DB::save($activity); return Redirect::route('page.activities', ['id' => $id])->with('success', 'Successfully added new activity')->send(); }
function TraceIncomingCall() { require_once 'include/utils/utils.php'; global $adb, $current_user; global $theme, $app_strings; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $sql = "select * from vtiger_asteriskextensions where userid = " . $current_user->id; $result = $adb->query($sql); $asterisk_extension = $adb->query_result($result, 0, "asterisk_extension"); $query = "select * from vtiger_asteriskincomingcalls where to_number = " . $asterisk_extension; $result = $adb->query($query); if ($adb->num_rows($result) > 0) { $callerNumber = $adb->query_result($result, 0, "from_number"); $callerName = $adb->query_result($result, 0, "from_name"); $callerType = $adb->query_result($result, 0, "callertype"); if (!empty($callerType)) { $caller = getCallerName("{$callerType}:" . $callerNumber); } else { $caller = getCallerName($callerNumber); } $adb->query("delete from vtiger_asteriskincomingcalls where to_number = " . $asterisk_extension); //prepare the div for incoming calls $status = "\t<table border='0' cellpadding='5' cellspacing='0'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style='padding:10px;' colspan='2'><b>Incoming Call</b></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t<table border='0' cellpadding='0' cellspacing='0' class='hdrNameBg'>\n\t\t\t\t\t\t<tr><td style='padding:10px;' colspan='2'><b>Caller Information</b>\n\t\t\t\t\t\t\t<br><b>Number:</b> {$callerNumber}\n\t\t\t\t\t\t\t<br><b>Name:</b> {$callerName}\n\t\t\t\t\t\t</td></tr>\n\t\t\t\t\t\t<tr><td style='padding:10px;' colspan='2'><b>Information from vtigerCRM</b>\n\t\t\t\t\t\t\t<br>{$caller}\n\t\t\t\t\t\t</td></tr>\n\t\t\t\t\t</table>"; require_once 'modules/Calendar/Activity.php'; $focus = new Activity(); $focus->column_fields['subject'] = "Incoming call from {$callerName} ({$callerNumber})"; $focus->column_fields['activitytype'] = "Call"; $focus->column_fields['date_start'] = date('Y-m-d'); $focus->column_fields['due_date'] = date('Y-m-d'); $focus->column_fields['time_start'] = date('H:i'); $focus->column_fields['time_end'] = date('H:i'); $focus->column_fields['eventstatus'] = "Held"; $focus->column_fields['assigned_user_id'] = $current_user->id; $focus->save('Calendar'); $callerInfo = getCallerInfo("{$callerType}:" . $callerNumber); if ($callerInfo == false) { $callerInfo = getCallerInfo(getStrippedNumber($callerNumber)); } if ($callerInfo != false) { $tablename = array('Contacts' => 'vtiger_cntactivityrel', 'Accounts' => 'vtiger_seactivityrel', 'Leads' => 'vtiger_seactivityrel'); $sql = "insert into " . $tablename[$callerInfo['module']] . " values (?,?)"; $params = array($callerInfo[id], $focus->id); $adb->pquery($sql, $params); } } else { $status = "failure"; } return $status; }
/** * Test Activity */ public function testActivityCRUD() { $activity = new Activity(); $activity->_id = \app\locker\helpers\Helpers::getRandomValue(); $activity->definition = array('type' => \app\locker\helpers\Helpers::getRandomValue(), 'name' => array('en-US' => \app\locker\helpers\Helpers::getRandomValue()), 'description' => array('en-US' => \app\locker\helpers\Helpers::getRandomValue())); $result = $activity->save(); $this->assertTrue($result); // Load activity from db $aid = $activity->_id; $db_activity = Activity::find($aid); $this->assertEquals($db_activity->_id, $activity->_id); // Delete activity $db_activity->delete(); $this->assertEquals(Activity::find($aid), NULL); }
public function destroy($id) { $ac = Activity::find($id); $ac->delete(); Session::flash('success', 'Data telah dihapus.'); return Redirect::to('/' . Auth::user()->role . '/activity'); }
public function sheet($leadership_event_id, $activity_id) { $event = LeadershipEvent::findOrFail($leadership_event_id); $activity = Activity::findOrFail($activity_id); $this->layout->with('subtitle', $event->name()); $this->layout->content = View::make('signup.sheet')->with('event', $event)->with('activity', $activity); }
public function local() { // Local file upload try { if (empty($_FILES['file']) || !is_uploaded_file($_FILES['file']['tmp_name'])) { throw new Exception("Something went wrong with uploading this file. The file may be too large to upload."); } $tmp_file = $_FILES['file']; $dst = STORAGE_PATH . "/uploads/" . $tmp_file["name"]; $this->ensureGoodFile($tmp_file); if (file_exists($dst)) { unlink($dst); } // Create the directory structure if it doesn't exist if (!is_dir(dirname($dst))) { mkdir(dirname($dst), 0777, true); } rename($tmp_file["tmp_name"], $dst); $file = FileUploadHandler::fromName("uploads/" . $tmp_file["name"]); Activity::log("uploaded a new file called " . $file->getLink() . "."); //send us to step 2. $this->forwardToUrl("/job/create/file:{$file->id}"); } catch (Exception $e) { $this->set('megaerror', $e->getMessage()); } }
public function destroy($id) { Admin::where('id', '=', $id)->delete(); Activity::log(['contentId' => $id, 'user_id' => Auth::admin()->get()->id, 'contentType' => 'Administrador', 'action' => 'Delete ', 'description' => 'Eliminacion de un administrador', 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $id ? true : false]); $output['success'] = 'deleted'; return Response::json($output, 200); }
public function activity($activity_limit = 5) { $users = $comments = $activity_type = array(); $issue = $this; $project_id = $this->project_id; $project = \Project::find($project_id); foreach (\Activity::all() as $row) { $activity_type[$row->id] = $row; } $activities = array(); foreach (\User\Activity::where('item_id', '=', $issue->id)->order_by('created_at', 'ASC')->get() as $activity) { $activities[] = $activity; switch ($activity->type_id) { case 2: if (!isset($users[$activity->user_id])) { $users[$activity->user_id] = \User::find($activity->user_id); } if (!isset($comments[$activity->action_id])) { $comments[$activity->action_id] = \Project\Issue\Comment::find($activity->action_id); } break; case 5: if (!isset($users[$activity->user_id])) { $users[$activity->user_id] = \User::find($activity->user_id); } if (!isset($users[$activity->action_id])) { $users[$activity->action_id] = \User::find($activity->action_id); } break; default: if (!isset($users[$activity->user_id])) { $users[$activity->user_id] = \User::find($activity->user_id); } break; } } /* Loop through the projects and activity again, building the views for each activity */ $return = array(); foreach ($activities as $row) { switch ($row->type_id) { case 2: $return[] = \View::make('project/issue/activity/' . $activity_type[$row->type_id]->activity, array('issue' => $issue, 'project' => $project, 'user' => $users[$row->user_id], 'comment' => $comments[$row->action_id], 'activity' => $row)); break; case 3: $return[] = \View::make('project/issue/activity/' . $activity_type[$row->type_id]->activity, array('issue' => $issue, 'project' => $project, 'user' => $users[$row->user_id], 'activity' => $row)); break; case 5: $return[] = \View::make('project/issue/activity/' . $activity_type[$row->type_id]->activity, array('issue' => $issue, 'project' => $project, 'user' => $users[$row->user_id], 'assigned' => $users[$row->action_id], 'activity' => $row)); break; case 6: $tag_diff = json_decode($row->data, true); $return[] = \View::make('project/issue/activity/' . $activity_type[$row->type_id]->activity, array('issue' => $issue, 'project' => $project, 'user' => $users[$row->user_id], 'tag_diff' => $tag_diff, 'tag_counts' => array('added' => sizeof($tag_diff['added_tags']), 'removed' => sizeof($tag_diff['removed_tags'])), 'activity' => $row)); break; default: $return[] = \View::make('project/issue/activity/' . $activity_type[$row->type_id]->activity, array('issue' => $issue, 'project' => $project, 'user' => $users[$row->user_id], 'activity' => $row)); break; } } return $return; }
public function postPolling() { $polls = json_decode(Input::get('polls')); $_results = array(); if (is_array($polls) && count($polls) > 0) { foreach ($polls as $i => $_poll) { switch ($_poll->type) { case "plugin": if ($_poll->func) { $_results[$_poll->id] = call_user_func($_poll->func, $_poll->value); } break; case "check_logs": $list = Activity::whereRaw('UNIX_TIMESTAMP(`activity_log`.`created_at`) > ? AND (activity_log.content_type="notification" OR activity_log.content_type="login")', array(Session::get('usersonline_lastcheck', time())))->select(array('description', 'details', 'users.displayname', 'content_type'))->groupBy(DB::raw('description, details, users.displayname, content_type'))->orderBy('activity_log.id', 'DESC')->leftJoin('users', 'users.id', '=', 'activity_log.user_id')->get()->toArray(); Session::put('usersonline_lastcheck', time()); $_results[$_poll->id] = array('type' => 'function', 'func' => 'fnUpdateGrowler', 'args' => $list); break; case "users_online": $_results[$_poll->id] = array('type' => 'html', 'args' => Theme::make('admin/helpers/users-online')->render()); break; } } } return Response::json($_results); }
public function create() { $this->assertLoggedIn(); $this->setTitle('Create a New Queue'); if ($this->args('submit')) { //did we get a name? if (!$this->args('name')) { $errors['name'] = "You need to provide a name."; $errorfields['name'] = 'error'; } //okay, we good? if (empty($errors)) { //woot! $q = new Queue(); $q->set('name', $this->args('name')); $q->set('user_id', User::$me->id); $q->save(); //todo: send a confirmation email. Activity::log("created a new queue named " . $q->getLink() . "."); $this->forwardToUrl($q->getUrl()); } else { $this->set('errors', $errors); $this->set('errorfields', $errorfields); $this->setArg('name'); } } }
/** * @see RedBeanModel::getHasBean() */ public static function getCanHaveBean() { if (get_called_class() == 'MashableActivity') { return self::$canHaveBean; } return parent::getCanHaveBean(); }
public function Parallax() { $menus = Menu::roots()->get(); $menu = Menu::where('slug', '/anasayfa')->first(); \Activity::log('Ziyaret: Anasayfa (Tek Sayfa Site)'); return view('parallax')->with(['menus' => $menus, 'menu' => $menu]); }
public function action_index() { $this->template->title = __('Contact'); $this->template->content = View::factory('page/contact')->bind('errors', $errors); // Validate the required fields $data = Validate::factory($_POST)->filter('name', 'trim')->rule('name', 'not_empty')->filter('email', 'trim')->rule('email', 'not_empty')->rule('email', 'email')->filter('message', 'trim')->filter('message', 'Security::xss_clean')->filter('message', 'strip_tags')->rule('message', 'not_empty'); if ($data->check()) { // Load Swift Mailer require Kohana::find_file('vendor', 'swiftmailer/lib/swift_required'); $transport = Swift_MailTransport::newInstance(); $mailer = Swift_Mailer::newInstance($transport); // Get the email config $config = Kohana::config('site.contact'); $recipient = $config['recipient']; $subject = $config['subject']; // Create an email message $message = Swift_Message::newInstance()->setSubject(__($subject, array(':name' => $data['name'])))->setFrom(array($data['email'] => $data['name']))->setTo($recipient)->addPart($data['message'], 'text/plain'); // Send the message Swift_Mailer::newInstance($transport)->send($message); // Set the activity and flash message Activity::set(Activity::SUCCESS, __('Message sent from :email', array(':email' => $data['email']))); Message::set(Message::SUCCESS, __('Message successfully sent.')); // Redirect to prevent POST refresh $this->request->redirect($this->request->uri); } if ($errors = $data->errors('contact')) { // Set the error flash message Message::set(Message::ERROR, __('Please correct the errors.')); } $_POST = $data->as_array(); }
/** * After validate event * @return object */ public function afterValidate() { if (count($this->ids)) { $save = array(); // The values we would like to check if they were changed // key = value from this model // value = value from the tickets model $valuesChanged = array('status' => 'ticketstatus', 'type' => 'tickettype', 'category' => 'ticketcategory', 'priority' => 'priority', 'version' => 'ticketversion', 'fixedin' => 'fixedin', 'assignedtoid' => 'assignedtoid'); // Loop the values foreach ($valuesChanged as $key => $value) { if ($this->{$key}) { $save[$value] = $this->{$key}; } } // Only update if we have any if (count($save)) { // Update all the ticket ids Tickets::model()->updateByPk($this->ids, $save); // Load one ticket model $model = Tickets::model()->findByPk(reset($this->ids)); $this->activity['projectid'] = $model->projectid; $this->activity['type'] = Activity::TYPE_TICKET; $this->activity['title'] = 'Used multi-Moderation to update <strong>{n}</strong> {title}.'; // Append project params $this->activity['params'] = array_merge($this->activity['params'], array('{n}' => count($this->ids), '{title}' => CHtml::link(Yii::t('tickets', 'Tickets'), array('/tickets')))); // Activity: New Project Activity::log($this->activity); } } return parent::afterValidate(); }