/** * Class Constructor * * @param App Reference to the global App object */ public function __construct($app) { parent::__construct($app); // load class $this->app->loader->register('AppEvent', 'classes:event.php'); $this->app->loader->register('AppEventDispatcher', 'classes:event.php'); // set dispatcher if (!isset(self::$_dispatcher)) { self::$_dispatcher = new AppEventDispatcher(); } }
public function beforeSave($event) { $tmp_event_id = 0; $is_change = false; $role = User::model()->getUserRole(); if (!$this->owner->isNewRecord && $role != 'Manager' && $role != 'Admin') { $tmp_event_id = time(); foreach ($this->old_attributes as $key => $value) { if ($key == 'max_exec_date') { $old_value = Yii::app()->dateFormatter->format($this->owner->dateTimeOutcomeFormat, strtotime($value)); $new_value = Yii::app()->dateFormatter->format($this->owner->dateTimeOutcomeFormat, strtotime($this->owner->max_exec_date)); if ($old_value === $new_value) { continue; } } else { $old_value = $value; $new_value = $this->owner->{$key}; } if ($old_value != $new_value) { $is_change = true; $moderate = new Moderate(); $moderate->event_id = $tmp_event_id; $moderate->class_name = get_class($this->owner); $moderate->id_record = $this->owner->primaryKey; $moderate->attribute = $key; $moderate->old_value = $old_value; $moderate->new_value = $new_value; $moderate->save(false); } } if ($is_change) { Yii::import('application.modules.project.components.EventHelper'); switch (get_class($this->owner)) { case 'Profile': $event_id = EventHelper::updateProfile(); break; case 'Zakaz': $event_id = EventHelper::editOrder($this->owner->primaryKey); break; } Moderate::model()->updateAll(['event_id' => $event_id], 'event_id=:event_id', [':event_id' => $tmp_event_id]); } $this->owner->attributes = $this->old_attributes; } }
public function manager() { // Дата информирования менеджера $projectsModel = Zakaz::model()->findAll('status<>:status', array(':status' => 5)); foreach ($projectsModel as $project) { $dateStart = strtotime(date('Y-m-d H:i', time())) - self::INTERVAL * 60; //echo 'order #'.$project->id.' '.$project->title.': '.$project->manager_informed."\n"; if (strtotime(date('Y-m-d H:i', strtotime($project->manager_informed))) >= $dateStart && strtotime(date('Y-m-d H:i', strtotime($project->manager_informed))) < strtotime(date('Y-m-d H:i', time()))) { //echo Company::getId().' #'.$project->id.' manager informed'."\n"; Yii::import('application.modules.project.components.EventHelper'); EventHelper::managerInformed($project->id); } } // У части заказа незавершенного заказа $projectsPartsModel = ZakazParts::model()->findAllByAttributes(array('status_id' => '1')); foreach ($projectsPartsModel as $projectStage) { $dateStart = strtotime(date('Y-m-d H:i', time())) - self::INTERVAL * 60; if (strtotime(date('Y-m-d H:i', strtotime($projectStage->date))) >= $dateStart && strtotime(date('Y-m-d H:i', strtotime($projectStage->date))) < strtotime(date('Y-m-d H:i', time()))) { Yii::import('application.modules.project.components.EventHelper'); EventHelper::stageExpired($projectStage->proj_id); } } }
function getStartAndEndDates() { return EventHelper::formatted_alldates($this->obj('StartDateTime'), $this->obj('EndDateTime')); }
/** * This method will clear the event cache generated by this module for the site and page * @todo implement something to call this */ function clear_cache($site_id = '', $page_id = '') { $site_id = $site_id ? $site_id : $this->site_id; $page_id = $page_id ? $page_id : $this->page_id; if ($site_id && $page_id) { $qh = new EventHelper($site_id, $page_id); } $qh->clear_cache(); }
echo TextHelper::_('COBALT_NAME'); ?> </div> <div class="cobaltValue"> <input type="text" class="form-control" name="name" value="" /> </div> </div> <div class="cobaltRow"> <div class="cobaltField"><?php echo TextHelper::_('COBALT_CATEGORY'); ?> </div> <div class="cobaltValue"> <select data-native-menu="false" data-overlay-theme="a" data-theme="c" name="category_id" tabindex="-1"> <?php $categories = EventHelper::getCategories(); echo JHtml::_('select.options', $categories, 'value', 'text', "", true); ?> </select> </div> </div> <div class="cobaltRow"> <div class="cobaltField"></div> <div class="cobaltValue"> <label for="due_date"><?php echo TextHelper::_('COBALT_DUE_DATE'); ?> :</label> <input type="date" name="due_date_hidden" class="form-control" id="due_date" value="" /> <input type="hidden" name="due_date" id="due_date_hidden" value="" /> </div>
public function actionStatus() { $status_id = Yii::app()->request->getPost('status_id'); $id = Yii::app()->request->getPost('id'); if (User::model()->isAuthor() && $status_id == '+1' && $id) { $stage = ZakazParts::model()->findByPk($id); if (User::model()->isExecutor($stage->proj_id) && $stage->status_id == 1) { $stage->status_id = 2; $stage->save(); echo $stage->status->status; EventHelper::stageDoneByExecutor($stage->proj_id, $stage->title); } else { echo 'Wrong base status'; } } elseif (User::model()->isCustomer() && $status_id == '+1' && $id) { $stage = ZakazParts::model()->findByPk($id); if (User::model()->isOwner($stage->proj_id) && $stage->status_id == 3) { $stage->status_id = 4; $stage->save(); //echo $stage->status->status; echo ProjectModule::t('Approved by me'); EventHelper::stageDoneByCustomer($stage->proj_id, $stage->title); } else { echo 'Wrong base status'; } } elseif (User::model()->isManager() && $status_id && $id) { $orderId = Yii::app()->request->getPost('orderId'); $row = array('status_id' => $status_id); $condition = array(); $params = array(); ZakazParts::model()->updateByPk($id, $row, $condition, $params); if ((int) $status_id == 3) { $parts = ZakazParts::model()->findAll("`proj_id` = '{$orderId}' AND `status_id` IN (0,1,2)"); $order = Zakaz::model()->resetScope()->findByPk($orderId); $subject_order = $order->title; $user_id = $order->user_id; $user = User::model()->findByPk($user_id); $order->setCustomerEvents(2); $email = new Emails(); if (count($parts) > 0) { $type_id = Emails::TYPE_14; } else { $type_id = Emails::TYPE_15; } $rec = Templates::model()->findAll("`type_id`='{$type_id}'"); echo count($parts); $title = $rec[0]->title; $body = $rec[0]->text; $email->name = $user->full_name; if (strlen($email->name) < 2) { $email->name = $user->username; } $email->num_order = $orderId; // $model->date = date('Y-m-d H:i:s'); $email->subject_order = $subject_order; $email->num_order = $orderId; $email->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId; $email->sendTo($user->email, $rec[0]->title, $rec[0]->text, $type_id); } } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionAdd($project) { if (!Yii::app()->request->isAjaxRequest) { return false; } /*/ --- кампании $c_id = Campaign::getId(); if ($c_id) { ProjectChanges::$table_prefix = $c_id.'_'; ProjectChanges::$file_path = 'uploads/c'.$c_id.'/changes_documents'; } else { ProjectChanges::$file_path = 'uploads/changes_documents'; } // --- */ $model = new ProjectChanges(); $model->scenario = 'add'; $model->project_id = (int) $project; if (isset($_POST['ProjectChanges'])) { $model->attributes = $_POST['ProjectChanges']; $model->fileupload = CUploadedFile::getInstance($model, 'fileupload'); if (!empty($model->fileupload)) { $model->file = 'no'; } else { echo CJSON::encode(array('test' => array('text' => 'file-not-uploaded'))); Yii::app()->end(); } if (ProjectChanges::approveAllowed()) { $model->moderate = 1; } else { $model->moderate = 0; } if (!$model->validate()) { echo CJSON::encode(array('error' => CJSON::decode(CActiveForm::validate($model)))); Yii::app()->end(); } try { if ($model->isAllowedAdd() && $model->save(false)) { if (!(User::model()->isManager() || User::model()->isAdmin())) { EventHelper::addChanges($model->project_id); } echo CJSON::encode(array('success' => true)); Yii::app()->end(); } else { echo CJSON::encode(array('error' => array('text' => 'Вы не можете внести правки к этому проекту!'))); Yii::app()->end(); } } catch (CException $e) { echo YII_DEBUG ? CJSON::encode(array('error' => array('text' => $e->getMessage()))) : CJSON::encode(array('error' => array('text' => 'Ошибка добавления!'))); Yii::app()->end(); } } }
public function actionUpload() { if ($_GET['id']) { $id = intval($_GET['id']); } if ($_GET['unixtime']) { $unixtime = intval($_GET['unixtime']); } $folder = Yii::getPathOfAlias('webroot') . '/uploads/c' . Company::getId(); if ($id) { $folder .= '/' . $id . '/'; } else { $folder .= '/temp/' . $unixtime . '/'; } $result = Tools::uploadMaterials($folder); echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); if ($id && $result['success'] && User::model()->isCustomer()) { EventHelper::materialsAdded($id); } }
public function actionRegistration() { $model = new RegistrationForm(); $this->performAjaxValidation($model); if (isset($_GET['role']) && $_GET['role'] == 'Customer') { $role = 'Customer'; } elseif (isset($_GET['role']) && $_GET['role'] == 'Author') { $role = 'Author'; /*} elseif(isset($_GET['role']) && $_GET['role']=='Manager') { $role = 'Manager';*/ } elseif (isset($_GET['role']) && $_GET['role'] == 'Webmaster') { $role = 'Webmaster'; } else { $role = 'Customer'; } if (Yii::app()->user->id && (!Yii::app()->user->hasFlash('reg_success') && !Yii::app()->user->hasFlash('reg_failed'))) { if ($role == 'Author') { $this->redirect('/project/zakaz/list'); } else { $this->redirect(Yii::app()->controller->module->profileUrl); } } else { if (isset($_POST['RegistrationForm'])) { if (self::register($model, $_POST['RegistrationForm'], $role)) { Yii::import('project.components.EventHelper'); if ($role == 'Customer') { EventHelper::newCustomer(); } Yii::app()->user->setFlash('reg_success', UserModule::t("Thank you for your registration. Password has been sent to your e-mail. Please check your e-mail ({{email}}) before start.", ['{{email}}' => $model->email])); $this->refresh(); } else { $message = UserModule::t("Sorry, something wrong... :("); $errors = $model->errors; if (isset($errors['email'])) { $message = $errors['email'][0]; } //Yii::app()->end(); Yii::app()->user->setFlash('reg_failed', $message); //$this->refresh(); } } Yii::app()->theme = 'client'; $this->render('/user/registration', array('model' => $model, 'role' => $role)); } }
public function actionAffiliatePayment() { //print_r($_REQUEST); //Yii::app()->end(); $hashSecretWord = Campaign::getPayment2ChekoutHash(); //2Checkout Secret Word $hashSid = Campaign::getPayment2Chekout(); //2Checkout account number $hashTotal = $_REQUEST['total']; //Sale total to validate against $hashOrder = $_REQUEST['order_number']; //2Checkout Order Number ---- =1 for test!! $StringToHash = strtoupper(md5($hashSecretWord . $hashSid . $hashOrder . $hashTotal)); if ($StringToHash != $_REQUEST['key']) { $result = 'Fail - Hash Mismatch'; } else { $result = 'Success - Hash Matched'; $orderId = $_REQUEST['li_0_product_id']; $payment = ProjectPayments::model()->find('order_id = :ORDER_ID', array('ORDER_ID' => $orderId)); $payment->received = $payment->received + $hashTotal; $payment->to_receive -= $hashTotal; if ($payment->save() && $hashTotal != 0) { $order = Zakaz::model()->resetScope()->findByPk($orderId); if ($order->status < 3) { $order->status = 3; } $order->save(); if ($payment->received == $payment->project_price) { $this->saveFullPaymentWebmasterLog($order); } $buh = new Payment(); $buh->order_id = $orderId; $buh->receive_date = date('Y-m-d H:i:s'); $buh->theme = $order->title; $user = User::model()->findByPk($order->user_id); $buh->user = $user->email; $buh->summ = (double) $hashTotal; $buh->payment_type = Payment::INCOMING_CUSTOMER; $buh->manager = '*****@*****.**'; $buh->approve = 1; $buh->method = 'Bank'; if ($buh->save()) { echo 'ok'; //Yii::app()->user->setFlash('tipDay','Данные сохранены'); EventHelper::payForOrder($orderId); $this->redirect(array('/project/chat', 'orderId' => $orderId)); } else { echo 'Error! Can\'t save buh-payment'; } } else { echo 'Error! Can\'t save order-payment'; } } //echo $result; }
public function actionUploadPayment($id) { if (isset($_POST['UploadPaymentImage'])) { $upload = new UploadPaymentImage(); $upload->orderId = $id; $upload->file = CUploadedFile::getInstance($upload, 'file'); if ($upload->file && $upload->validate()) { $upload->save(); EventHelper::chekUploaded($id); } } $this->redirect(['chat/index', 'orderId' => $id]); }
public function beforeSave($event) { $tmp_event_id = 0; $is_change = false; $role = User::model()->getUserRole(); if (!$this->owner->isNewRecord && $role != 'Manager' && $role != 'Admin') { $tmp_event_id = time(); foreach ($this->old_attributes as $key => $value) { if ($key == 'max_exec_date') { $old_value = Yii::app()->dateFormatter->format($this->owner->dateTimeOutcomeFormat, strtotime($value)); $new_value = Yii::app()->dateFormatter->format($this->owner->dateTimeOutcomeFormat, strtotime($this->owner->max_exec_date)); if ($old_value === $new_value) { continue; } } else { $old_value = $value; $new_value = $this->owner->{$key}; } if ($old_value != $new_value && !(User::model()->isCorrector() && $key == 'technicalspec') && $key != 'executor_event' && $key != 'customer_event') { $is_change = true; $moderate = new Moderate(); $moderate->event_id = $tmp_event_id; $moderate->class_name = get_class($this->owner); $moderate->id_record = $this->owner->primaryKey; $moderate->attribute = $key; $moderate->old_value = $old_value; $moderate->new_value = $new_value; $moderate->save(false); } } if ($is_change) { Yii::import('application.modules.project.components.EventHelper'); switch (get_class($this->owner)) { case 'Profile': $event_id = EventHelper::updateProfile(); break; case 'Zakaz': $event_id = EventHelper::editOrder($this->owner->primaryKey); break; } Moderate::model()->updateAll(['event_id' => $event_id], 'event_id=:event_id', [':event_id' => $tmp_event_id]); } if (User::model()->isCorrector() && $this->owner->attributes['technicalspec'] != $this->old_attributes['technicalspec']) { $this->old_attributes['technicalspec'] = $this->owner->attributes['technicalspec']; } $this->old_attributes['executor_event'] = $this->owner->attributes['executor_event']; $this->old_attributes['customer_event'] = $this->owner->attributes['customer_event']; $this->owner->attributes = $this->old_attributes; } else { if (!$this->owner->isNewRecord && get_class($this->owner) == 'Zakaz') { $authorInformedUpdated = false; foreach ($this->old_attributes as $key => $value) { $old_value = $value; $new_value = $this->owner->{$key}; if ($old_value != $new_value && $key != 'executor_event' && $key != 'customer_event') { $is_change = true; } if ($old_value != $new_value && $key == 'author_informed') { $authorInformedUpdated = true; } } if ($authorInformedUpdated) { if ($this->owner->executor_event) { $events = explode(",", $this->owner->executor_event); if (!in_array(3, $events)) { $events[] = 3; $this->owner->executor_event = implode(",", $events); } } else { $this->owner->executor_event = 3; } } elseif ($is_change) { if ($this->owner->executor_event) { $events = explode(",", $this->owner->executor_event); if (!in_array(1, $events)) { $events[] = 1; $this->owner->executor_event = implode(",", $events); } } else { $this->owner->executor_event = 1; } } } } }
/** * An export function which displays title, intro, publication/event * titles and dates, with events grouped by month. * * Output looks like: * <code> * <h1>A Newsletter Title</h1> * <p>A newsletter description blah blah</p> * <h2>Recent News</h2> * <h3>The name of a publication</h3> * <ul> * <li><a target="_blank" href="some_story_url">A post</a> (Wed, May 19 2010 9:23 am)</li> * <li><a target="_blank" href="some_story_url">A post</a> (Wed, May 19 2010 9:23 am)</li> * </ul> * <h2>Upcoming Events</h2> * <h3>April 2010</h3> * <ul> * <li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Thu, Apr 15 2010)</li> * <li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Fri, Apr 16 2010)</li> * </ul> * <h3>May 2010</h3> * <ul> * <li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Thu, May 15 2010)</li> * <li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Fri, May 16 2010)</li> * </ul> * </code> * * @param array the data to be transformed. * @return array the transformed data */ function _export_headings_only_events_by_month($data) { $output = ""; if ($data['info']['title']) { $output = '<h1>' . $data['info']['title'] . '</h1>'; } if ($data['info']['intro']) { $output .= '<p>' . $data['info']['intro'] . '</p>'; } if (!empty($data['pubs'])) { $output .= "<h2>Recent News</h2>"; foreach ($data['pubs'] as $pub_id => $pub_posts) { $pub_ent = new Entity($pub_id); $output .= '<h3>' . $pub_ent->get_value('name') . '</h3>'; $output .= "<ul>"; foreach ($pub_posts as $pub_post) { $output .= '<li><a target="_blank" href="' . $data['info']['urls'][$pub_id] . "?story_id=" . $pub_post->get_value('id') . '">' . $pub_post->get_value('name') . '</a> (' . date("D, M j Y g:i a", strtotime($pub_post->get_value('datetime'))) . ')</li>'; } $output .= "</ul>"; } } if (!empty($data['events'])) { $output .= "<h2>Upcoming Events</h2>"; foreach ($data['events'] as $day => $events) { $events_by_month[date("M-Y", strtotime($day))][$day] = $events; } foreach ($events_by_month as $month => $day) { $output .= "<h3>" . date("F Y", strtotime($month)) . "</h3>"; $output .= "<ul>"; foreach ($day as $day => $events) { foreach ($events as $event) { $eHelper = new EventHelper(); @$eHelper->set_page_link($event); $eventURL = $event->get_value('url') . date("Y-m-d", strtotime($day)); $output .= '<li><a target="_blank" href="' . $eventURL . '">' . $event->get_value('name') . '</a> (' . date("D, M j", strtotime($day)) . " at " . date("g:i a", strtotime(preg_replace('/^.*[^ ] /', '', $event->get_value('datetime')))) . ')</li>'; } } $output .= "</ul>"; } } return tidy($output); }
function init($args = array()) { parent::init($args); if ($this->controller->get_current_step() != 'SelectItems') { return; } if ($this->controller->get_form_data('selected_publications') != '' || $this->controller->get_form_data('events_start_date') != '') { $this->add_element('select_instructions', 'comment', array('text' => '<p>Items from the publications and calendar dates which you picked are displayed below. Select the posts and events that you would like to include in your newsletter from the lists below.</p>')); } if ($this->controller->get_form_data('selected_publications') != '') { $pubs = $this->controller->get_form_data('selected_publications'); $this->add_element('pub_items_header', 'comment', array('text' => '<h2 class="region">Posts</h2>')); foreach ($pubs as $pub) { $post_options = array(); $ph_new = new PublicationHelper($pub); if ($startDate = $this->controller->get_form_data('publication_start_date')) { $ph_new->set_start_date($startDate); } if ($endDate = $this->controller->get_form_data('publication_end_date')) { $ph_new->set_end_date($endDate); } $pub_posts = $ph_new->get_published_items(); $page_of_publication = $ph_new->get_right_relationship('page_to_publication'); if ($pub_posts) { foreach ($pub_posts as $pub_post) { $available_posts[$pub][$pub_post->get_value('id')] = array('id' => $pub_post->get_value('id'), 'name' => $pub_post->get_value('name'), 'date_released' => $pub_post->get_value('datetime'), 'created_by' => $pub_post->get_value('created_by'), 'url' => reason_get_page_url($page_of_publication[0]->get_value('id')) . "?story_id=" . $pub_post->get_value('id')); } } if (!empty($available_posts)) { if (empty($available_posts[$pub])) { $this->add_element("pub_items_number_{$pub}", 'comment', array('text' => '<p>No live posts were found for the publication "' . $ph_new->get_value('name') . '".</p>')); } else { $count = count($available_posts[$pub]); $text = "{$count}" . ($count > 1 ? ' posts were' : ' post was'); $text .= ' found for the publication "' . $ph_new->get_value('name') . '"'; foreach ($available_posts[$pub] as $post) { $post_options[$post['id'] . '_post'] = $post['name'] . ' (<a target="_blank" href="' . $post['url'] . '">link</a>)'; // $this->add_element($item['id'].'_info', 'comment', array('text' => '<p>Date released: '.$item['date_released'].'</p>')); } $this->add_element("pub_posts_group_{$pub}", 'checkboxgroup', array('options' => $post_options)); $this->set_display_name("pub_posts_group_{$pub}", $text); } } else { $this->add_element("pub_items_none_{$pub}", 'comment', array('text' => '<p>No posts were found for "' . $ph_new->get_value('name') . '" during the selected timeframe.</p>')); } } } if ($this->controller->get_form_data('events_start_date') != '') { $site_id = (int) $_REQUEST['site_id']; $site = new entity($site_id); $start_date = $this->controller->get_form_data('events_start_date'); $end_date = $this->controller->get_form_data('events_end_date'); $end_date = !empty($end_date) ? $end_date : date('Y-m-d'); $cal = new reasonCalendar(array('site' => $site, 'start_date' => $start_date, 'end_date' => $end_date)); $cal->run(); $events = $cal->get_all_events(); $days = $cal->get_all_days(); $this->add_element('events_header', 'comment', array('text' => '<h2 class="region">Calendar events</h2>')); if ($days) { // This is a bit of a hack. We want to know the number of deepest-level elements // _before_ we've iterated through the array, creating elements for each deepest-level // element... hence the double foreach. $count = 0; foreach ($days as $day => $event_ID_array) { foreach ($event_ID_array as $event_item) { $count++; } } $text = "<p>{$count}" . ($count > 1 ? ' calendar events were found.</p>' : ' calendar event was found.</p>'); $this->add_element('events_number', 'comment', array('text' => $text)); foreach ($days as $day => $event_ID_array) { $event_options = array(); $events_from_today = array(); foreach ($event_ID_array as $event_ID) { $events_from_today[$event_ID] = $events[$event_ID]; } uasort($events_from_today, "sort_events"); foreach ($events_from_today as $event_id => $event_item) { $prettyDate = date("g:i a", strtotime($event_item->get_value('datetime'))); $eHelper = new EventHelper(); @$eHelper->set_page_link($event_item); $eventURL = $event_item->get_value('url') . date("Y-m-d", strtotime($event_item->get_value('datetime'))); $event_options[$event_id . '_event'] = '<strong>' . $prettyDate . '</strong> ' . $event_item->get_value('name') . ' (<a target="_blank" href="' . $eventURL . '">link</a>)'; } $this->add_element('events_group_day_' . $day, 'checkboxgroup_no_sort', array('options' => $event_options)); $rows[] = date("D, M j Y", strtotime($day)); $elements_to_add_to_group['events_group_day_' . $day] = 'events_group_day_' . $day; } $args = array('rows' => $rows, 'use_element_labels' => false, 'use_group_display_name' => false, 'wrapper_class' => 'events_wrapper'); $this->add_element_group('wrappertable', 'events_group', $elements_to_add_to_group, $args); } else { $this->add_element('events_number', 'comment', array('text' => '<p>No events were found.</p>')); } } }
protected function getChanges() { $res = false; if (!empty($this->_modelSave)) { foreach ($this->_modelSave as $key => $value) { if ($this->{$key} != $value) { UpdateProfile::addRecord($key, $value, $this->{$key}); $res = true; } } if ($res) { // можно внести в конфигу Yii::import('application.modules.project.components.EventHelper'); EventHelper::updateProfile(); } } return $res; }
public function actionUpload() { Yii::import("ext.EAjaxUpload.qqFileUploader"); // --- кампании $c_id = Campaign::getId(); if ($c_id) { $folder = 'uploads/c' . $c_id . '/' . $_GET['id'] . '/'; } else { $folder = 'uploads/' . $_GET['id'] . '/'; } // --- if (!file_exists($folder)) { mkdir($folder, 0777); } $config['allowedExtensions'] = array('png', 'jpg', 'jpeg', 'gif', 'txt', 'doc', 'docx'); $config['disAllowedExtensions'] = array("exe"); $sizeLimit = 10 * 1024 * 1024; // maximum file size in bytes $uploader = new qqFileUploader($config, $sizeLimit); if (!User::model()->isAdmin()) { $_GET['qqfile'] = '#pre#' . $_GET['qqfile']; } $result = $uploader->handleUpload($folder, true); if ($result['success'] && User::model()->isCustomer()) { EventHelper::materialsAdded($_GET['id']); } $result['fileSize'] = filesize($folder . $result['filename']); //GETTING FILE SIZE $result['fileName'] = $result['filename']; //GETTING FILE NAME chmod($folder . $result['fileName'], 0666); echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); }
public function actionUpload() { $folder = $this->folder(); $this->_prepairJson(); $folder = $_SERVER['DOCUMENT_ROOT'] . $folder; Yii::import("ext.EAjaxUpload.qqFileUploader"); //chmod($folder, 0777); // !-----------------------------DeBuG oNlY !!----------------------------------------- $folder = $folder . 'temp/'; //chmod($folder, 0777); // !-----------------------------DeBuG oNlY !!----------------------------------------- $config['allowedExtensions'] = array('jpg', 'jpeg', 'png', 'gif', 'txt', 'doc', 'docx'); $config['disAllowedExtensions'] = array("exe, php"); $sizeLimit = 10 * 1024 * 1024; $pi = pathinfo($_GET['qqfile']); $_GET['qqfile'] = $pi['filename'] . '_' . $_GET['id'] . '.' . $pi['extension']; $uploader = new qqFileUploader($config, $sizeLimit); $this->result = $uploader->handleUpload($folder, true); if ($this->result['success']) { $part = ZakazParts::model()->findByPk($_GET['id']); if (!User::model()->isManager()) { EventHelper::partDone($_GET['proj_id'], $part->title); } } chmod($folder . $_GET['qqfile'], 0666); if (User::model()->isManager() || User::model()->isAdmin()) { $this->_file_data['part_id'] = $_GET['id']; $this->_file_data['orig_name'] = $pi['filename'] . '.' . $pi['extension']; $this->_file_data['id'] = 0; $this->_file_data['req'] = 1; $this->actionApiApprove(); } //$this->result['html']='=)';//'<li>!!!<a href="' . $this->result['file_name'] . '" id="parts_file">' . $_GET['qqfile'] . '</a></li>'; $this->result = array('test' => $this->result['error']); $this->_response->setData($this->result); $this->_response->send(); }
public function actionApiRenameFile() { $this->_prepairJson(); $data = $this->_request->getParam('data'); $path = Yii::getPathOfAlias('webroot') . $data['dir']; if (!file_exists($path)) { mkdir($path); } if (rename($path . $data['name'], $path . '#trash#' . $data['name'])) { EventHelper::materialsDeleted($_GET['orderId']); $this->_response->setData(true); } else { $this->_response->setData(false); } $this->_response->send(); }
echo $event['end_date']; } ?> " /> </div> </div> </div> <div class="cobaltRow"> <div class="cobaltField"><?php echo TextHelper::_('COBALT_EDIT_TASK_REPEAT'); ?> </div> <div class="cobaltValue"> <select class="form-control" name="repeats"> <?php $repeat_intervals = EventHelper::getRepeatIntervals(); echo JHtml::_('select.options', $repeat_intervals, 'value', 'text', $event['repeats'], true); ?> </select> </div> </div> <?php if (array_key_exists('repeats', $event) && $event['repeats'] != "none") { ?> <div class="cobaltRow"> <label class="checkbox"> </label> <div class="cobaltField"><?php echo TextHelper::_('COBALT_UPDATE_FUTURE_EVENTS'); ?> </div>
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionAdd($project) { if (!Yii::app()->request->isAjaxRequest) { return false; } $c_id = Company::getId(); if ($c_id) { ProjectChanges::$file_path = 'uploads/c' . $c_id . '/changes_documents'; } else { ProjectChanges::$file_path = 'uploads/changes_documents'; } $model = new ProjectChanges(); $model->scenario = 'add'; $model->project_id = (int) $project; if (isset($_POST['ProjectChanges'])) { $model->attributes = $_POST['ProjectChanges']; $model->fileupload = CUploadedFile::getInstance($model, 'fileupload'); if (!empty($model->fileupload)) { //$model->file = 'no'; } else { echo CJSON::encode(array('error' => array('text' => 'file-not-uploaded'))); Yii::app()->end(); } if (ProjectChanges::approveAllowed()) { $model->moderate = 1; } else { $model->moderate = 0; } if (!$model->validate()) { echo CJSON::encode(array('error' => array('text' => print_r($model->errors, true)))); Yii::app()->end(); } //echo CJSON::encode(array('error' => array('text' => 'Ups!'))); //Yii::app()->end(); try { if ($model->isAllowedAdd() && $model->save(false)) { if (!(User::model()->isManager() || User::model()->isAdmin())) { EventHelper::addChanges($model->project_id); } if ($model->moderate == 1) { $orderModel = Zakaz::model()->findByPk($model->project_id); $orderModel->setExecutorEvents(4); } echo CJSON::encode(array('success' => true)); Yii::app()->end(); } else { echo CJSON::encode(array('error' => array('text' => 'Вы не можете внести правки к этому проекту!'))); Yii::app()->end(); } } catch (CException $e) { echo YII_DEBUG ? CJSON::encode(array('error' => array('text' => $e->getMessage()))) : CJSON::encode(array('error' => array('text' => 'Ошибка добавления!'))); Yii::app()->end(); } } }