Version history (please keep backward compatible): 1.0, 2008-10-09: Cornelius Hansjakob
Author: Cornelius Hansjakob (cha@massiveart.com)
Example #1
0
 function __construct()
 {
     $this->__core = Core::getInstance();
     $this->__lib = $this->__core->getLib();
     $this->__uri = $this->__core->getUri();
     $this->__req = $this->__core->getRequest();
 }
Example #2
0
 public function getGoodsinfo()
 {
     $goodsinfos = array();
     $db = new Core();
     $query = "SELECT g.*,\n                  gv.field as gvkey,\n                  gv.value as gvvalue,\n                  o.telphone as mobile,\n                  o.order_quantity as goods_number,\n                  o.goods_value as goods_value\n                  FROM " . DB_PREFIX . "goodslist g\n                  LEFT JOIN  " . DB_PREFIX . "order o \n                  ON g.order_id=o.id\n                  LEFT JOIN  " . DB_PREFIX . "goodsextensionvalue gv \n                  ON g.order_id=gv.id\n                  WHERE \n                  1\n                  and o.order_id='" . $this->order_id . "'";
     $mresult = $db->query($query);
     if (!$mresult) {
         $this->BundleGoods = $goodsinfos;
         return;
     }
     foreach ($mresult as $result) {
         $goods = json_decode(urldecode($result['extensions']), 1);
         $goods['goods_number'] = $result['goods_number'];
         $goods['goods_value'] = $result['goods_value'];
         //$goods['mobile'] = $result['mobile'];
         if ($result['gvkey'] == 'session') {
             $goods['session'] = $result['gvvalue'];
         }
         $goodsinfos[$result['bundle_id']]['goods'][] = $goods;
     }
     //file_put_contents('./cache/mobile.txt',var_export($result,1));
     $query = "SELECT *\n                  FROM " . DB_PREFIX . "order \n                  \n                  WHERE \n                  1\n                  and order_id='" . $this->order_id . "'";
     $re = $db->query($query, '');
     $this->mobile = $re[0]['telphone'];
     // = '18021806556';
     $this->BundleGoods = $goodsinfos;
 }
 /**
  *  Query database.  Retrun all values from a table
  *
  *  @param $table     String   Table name
  *
  *  @returns   Object   Database records.  MySQL object
  */
 public function checkNeededDataGoogleSearchAnalytics($website)
 {
     $core = new Core();
     //Load core
     $mysql = new MySQL();
     //Load MySQL
     $now = $core->now();
     /* Identify date range */
     $dateStartOffset = self::GOOGLE_SEARCH_ANALYTICS_MAX_DATE_OFFSET + self::GOOGLE_SEARCH_ANALYTICS_MAX_DAYS;
     $dateStart = date('Y-m-d', strtotime('-' . $dateStartOffset . ' days', $now));
     $dateEnd = date('Y-m-d', strtotime('-' . self::GOOGLE_SEARCH_ANALYTICS_MAX_DATE_OFFSET . ' days', $now));
     /* Query database for dates with data */
     $query = "SELECT COUNT( DISTINCT date ) AS record, date FROM " . MySQL::DB_TABLE_SEARCH_ANALYTICS . " WHERE domain LIKE '" . $website . "' AND date >= '" . $dateStart . "' AND date <= '" . $dateEnd . "' GROUP BY date";
     $result = $mysql->query($query);
     /* Create array from database response */
     $datesWithData = array();
     foreach ($result as $row) {
         array_push($datesWithData, $row['date']);
     }
     /* Get date rante */
     $dates = $core->getDateRangeArray($dateStart, $dateEnd);
     /* Loop through dates, removing those with data */
     foreach ($dates as $index => $date) {
         if (in_array($date, $datesWithData)) {
             unset($dates[$index]);
         }
     }
     /* Reindex dates array */
     $dates = array_values($dates);
     $returnArray = array('dateStart' => $dateStart, 'dateEnd' => $dateEnd, 'datesWithNoData' => $dates);
     return $returnArray;
 }
 public function getAppRoute($route_name, $app_id = null)
 {
     if (!$this->mappingRepository) {
         $this->mappingRepository = $this->doctrine->getManager()->getRepository('UnifikSystemBundle:Mapping');
     }
     $mapping = $this->mappingRepository->findOneBy(array('app' => $app_id ? $app_id : $this->systemCore->getApplicationCore()->getApp()->getId(), 'type' => 'route', 'target' => $route_name), array('section' => 'ASC'));
     if ($mapping) {
         // Faut checker toutes les routes, à cause du mapping alias
         $routes = $this->router->getRouteCollection()->all();
         foreach ($routes as $name => $route) {
             if ($defaults = $route->getDefaults()) {
                 if (array_key_exists('_unifikRequest', $defaults) && array_key_exists('mappedRouteName', $defaults['_unifikRequest'])) {
                     $real_name = preg_replace('/^[aA-zZ]{2}__[A-Z]{2}__/', '', $defaults['_unifikRequest']['mappedRouteName']);
                     // On a trouvé la bonne route
                     if ($real_name == $route_name) {
                         return preg_replace('/^[aA-zZ]{2}__[A-Z]{2}__/', '', $name);
                     }
                 }
             }
         }
         // On a rien trouvé... on retourne la route "par défaut" de la section
         return 'section_id_' . $mapping->getSection()->getId();
     }
     // Aucun mapping... on fallback sur la premiere route disponible (?)
     $mapping = $this->mappingRepository->findOneBy(array('type' => 'route', 'target' => $route_name), array('section' => 'ASC'));
     if ($mapping) {
         return 'section_id_' . $mapping->getSection()->getId();
     }
     // Rien de concluant
     return null;
 }
 private function populatePPMTable($counter, $result_row)
 {
     $core = new Core();
     $number_Of_houses = $core->getNumberofHouses($this->loc_table, $result_row['location']);
     $this->total_num_of_houses += $number_Of_houses;
     $per_street_year = $number_Of_houses * 12;
     $this->total_expected += $per_street_year;
     $date_done = $result_row['date_done'];
     $done_till_date = $core->getTillDate($number_Of_houses, $date_done);
     $this->expected_rate += $done_till_date;
     $houses_serviced = $result_row['houses_serviced'];
     $this->total_num_of_houses_serviced += $houses_serviced;
     $status_tiil_date = $core->getStatusTillDate($number_Of_houses, $houses_serviced);
     $current_satus = $core->getcurrentStatus($houses_serviced, $number_Of_houses, $status_tiil_date);
     $calls_generated = $result_row['calls_gen'];
     $this->total_calls_gen += $calls_generated;
     $calls_completed = $result_row['calls_comp'];
     $this->total_calls_gen += $calls_completed;
     $no_access = $number_Of_houses - $houses_serviced;
     $this->no_access_loc += $no_access;
     $out = "";
     $id = $result_row['S/N'];
     $out .= " <tr>";
     $out .= "<td >{$counter}</td>\n\t<td ondblclick='myFunction(this," . $id . ")' id='job_id'>" . $result_row['job_id'] . "</td>\n\t<td>" . $result_row['location'] . "</td><td>" . $number_Of_houses . "</td><td>Monthly</td>";
     $out .= "<td>" . $per_street_year . "</td><td>" . $done_till_date . "</td>";
     $out .= "<td ondblclick='myFunction(this," . $id . ")' id='houses_serviced'>" . $houses_serviced . "</td>";
     $out .= "<td >" . $status_tiil_date . " % </td><td>" . $current_satus . " % </td>\n\t<td ondblclick='myFunction(this," . $id . ")' id='date_done'>" . $result_row['date_done'] . "</td>\n\t<td ondblclick='myFunction(this," . $id . ")' id='date_nect'>" . $result_row['date_next'] . "</td>";
     $out .= "<td ondblclick='myFunction(this," . $id . ")' id='calls_gen'>{$calls_generated}</td>";
     $out .= "<td ondblclick='myFunction(this," . $id . ")' id='calls_comp'>{$calls_completed}</td>\n\t<td ondblclick='myFunction(this," . $id . ")' id='inspection'>" . $result_row['inspection'] . "</td>\n\t<td ondblclick='myFunction(this," . $id . ")' id='noaccesslocresolved'>" . $result_row['noaccesslocresolved'] . "</td>";
     $out .= "<td>" . $no_access . "</td><td ondblclick='myFunction(this," . $id . ")' id='engineers_remark'>" . $result_row['engineers_remark'] . "</td></tr>";
     return $out;
 }
Example #6
0
 private function initInvoice()
 {
     $core = new Core();
     $this->invoiceNumber = $core->generatePreformerInvoiceNumber();
     $this->jobNumber = $core->generateCmJobId();
     $details = $core->getAllStockDetails($this->materials);
     $this->stockRows .= '<tr class="item-row" id="item0">' . '<td>1</td>' . '<td class="item-name"><textarea data-role="none" class="item_name" >' . $details['part_number'] . '</textarea></td>' . '<td class="description"><textarea disabled data-role="none" class="item_description">' . $details['description'] . '</textarea></td>' . '<td><span disabled  class="cost" data-role="none" id="unitCost1"><del>N</del>' . $details['price'] . '</span></td>' . '<td><textarea  disabled  class="qty" data-role="none" id="quantity1">1</textarea></td>' . '<td><span class="price" >0.00</span></td></tr>';
 }
Example #7
0
 public function testExchangeArraySetsPropertiesToNullIfKeysAreNotPresent()
 {
     $core = new Core();
     $core->exchangeArray(array('name' => 'some name', 'id' => 123));
     $core->exchangeArray(array());
     $this->assertNull($core->name, '"name" should have defaulted to null');
     $this->assertNull($core->id, '"id" should have defaulted to null');
 }
Example #8
0
 function updateSubscriberList($argArrPost)
 {
     $objCore = new Core();
     $varID = implode('\',\'', $argArrPost['frmSubscriberID']);
     $varWhere = "pkSubscriberID IN('" . $varID . "')";
     $this->delete(TABLE_SUBSCRIBERS, $varWhere);
     //***end here
     $objCore->setSuccessMsg(ADMIN_SUBSCRIBER_DELETE);
     return true;
 }
Example #9
0
 function printBeautifulPHPCode($sourceCode)
 {
     require_once CODE_BEAUTIFIER_REQ;
     require_once BEAUTIFIER_PATH . FILE_SEPARATOR . "HFile" . FILE_SEPARATOR . "HFile_php3.php";
     require_once BEAUTIFIER_PATH . FILE_SEPARATOR . "Output" . FILE_SEPARATOR . "Output_HTML.php";
     $highlighter = new Core(new HFile_php3(), new Output_HTML());
     echo "<pre>";
     echo $highlighter->highlight_text($sourceCode);
     echo "</pre>";
 }
Example #10
0
 function imageUpload($argFILES, $argVarDirLocation, $varThumbnailWidth = '', $varThumbnailHeight = '', $varMediumWidth = '', $varMediumHeight = '')
 {
     $objUpload = new upload();
     $objCore = new Core();
     $objUpload->setMaxSize();
     $objUpload->setDirectory($argVarDirLocation);
     $varIsImage = $objUpload->IsImageValid($argFILES['type']);
     if ($varIsImage) {
         $varImageExists = 'yes';
     } else {
         $varImageExists = 'no';
     }
     if ($varImageExists == 'no') {
         $objCore->setErrorMsg(IMAGE_TYPE_ERROR);
         return false;
     }
     if ($varImageExists == 'yes') {
         $objUpload->setTmpName($argFILES['tmp_name']);
         if ($objUpload->userTmpName) {
             $objUpload->setFileSize($argFILES['size']);
             $objUpload->setFileType($argFILES['type']);
             $varRandomNumber = $this->generateRandomKey();
             $fileName = $varRandomNumber . '_' . strtolower($argFILES['name']);
             $fileName = str_replace(' ', '_', $fileName);
             $objUpload->setFileName($fileName);
             $objUpload->startCopy();
             if ($objUpload->isError()) {
                 $thumbnailName1 = '_thumb';
                 $objUpload->setThumbnailName($thumbnailName1);
                 $objUpload->createThumbnail();
                 if ($varThumbnailWidth == '' && $varThumbnailHeight == '') {
                     $objUpload->setThumbnailSize();
                 } else {
                     $objUpload->setThumbnailSize($varThumbnailWidth, $varThumbnailHeight);
                 }
                 $varFileName = $objUpload->userFileName;
                 $varExt = substr(strrchr($varFileName, "."), 1);
                 $varThumbFileNameNoExt = substr($varFileName, 0, -(strlen($varExt) + 1));
                 $varThumbFileName = $varThumbFileNameNoExt . 'thumb.' . $varExt;
                 $thumbnailName1 = '';
                 $objUpload->setThumbnailName($thumbnailName1);
                 $objUpload->createThumbnail();
                 if ($varMediumWidth == '' && $varMediumHeight == '') {
                     $objUpload->setThumbnailSize();
                 } else {
                     $objUpload->setThumbnailSize($varMediumWidth, $varMediumHeight);
                 }
                 return $varFileName;
             } else {
                 $objCore->setErrorMsg(ERROR_ON_UPLOAD);
                 return false;
             }
         }
     }
 }
Example #11
0
 public function overdueproceess()
 {
     $time = 2100;
     //过期时间
     $db = new Core();
     /**
      * 查询与订单号相关的商品,订单中相关信息如积分等
      */
     $query = "SELECT \n    \t          g.*,\n    \t          o.order_id as new_order_id,\n    \t          o.pay_credits as pay_credits,\n    \t          o.user_id as user_id,\n    \t\t      o.integral_status as integral_status\n    \t          FROM " . DB_PREFIX . "goodslist g\n                  LEFT JOIN " . DB_PREFIX . "order o\n                  ON g.order_id=o.id\n                  WHERE o.pay_status = 1 \n                  and o.create_time<" . (time() - $time) . " limit 0,100";
     $goodses = $db->query($query);
     if (!$goodses) {
         return;
     }
     $ids = array();
     $newgoodses = array();
     foreach ($goodses as $goods) {
         $newgoodses[$goods['bundle_id']]['goods'][$goods['goods_id']]['id'] = $goods['goods_id'];
         $newgoodses[$goods['bundle_id']]['goods'][$goods['goods_id']]['goods_number'] += $goods['goods_number'];
         $newgoodses[$goods['bundle_id']]['goods'][$goods['goods_id']]['bundle_id'] = $goods['bundle_id'];
         $ids[] = $goods['order_id'];
         $credits[$goods['user_id']]['id'] = $goods['order_id'];
         $credits[$goods['user_id']]['order_id'] = $goods['new_order_id'];
         $credits[$goods['user_id']]['credit'] = $goods['pay_credits'];
         $credits[$goods['user_id']]['integral_status'] = $goods['integral_status'];
         //积分的状态
     }
     $this->BundleGoods = $newgoodses;
     foreach ($newgoodses as $bundle_id => $bundlegoodses) {
         $curl = $bundle_id . "curl";
         $this->{$curl} = $this->create_curl_obj($bundle_id);
         $this->init_curl($bundle_id);
         //$Re_Minus_updateStores = $this -> opBundle('updateStore', array('operation' => 'plus'));
     }
     $Re_Minus_updateStores = $this->opBundle('updateStore', array('operation' => 'plus'));
     $orderids = implode(",", $ids);
     if (!$orderids) {
         return false;
     }
     require_once CUR_CONF_PATH . 'lib/sms.class.php';
     require_once ROOT_PATH . 'lib/class/members.class.php';
     $members = new members();
     foreach ($credits as $user => $v) {
         if (!$v['credit']) {
             continue;
         }
         $re = $members->return_credit($user, $v['credit'], $v['order_id'], 'payments', 'OrderUpdate', 'cancle', '订单:' . $v['order_id'] . '被系统取消:' . $v['title'], $v['integral_status'], '取消订单');
         if (!$re['logid']) {
             return false;
         }
     }
     $query = "UPDATE " . DB_PREFIX . "order \n                  SET order_status=24,pay_status=3,is_completed=23\n                  WHERE pay_status=1 and id in(" . $orderids . ")";
     $result = $db->query_update($query);
 }
Example #12
0
 public final function init()
 {
     $this->O->xml();
     $this->hook('before_config');
     $this->hook('config');
     $this->hook('after_config');
     if (!$this->method) {
         // on récupère la methode pour le module
         $this->method = Filter::id($this->var_method, $_GET);
     }
     $this->setMethod($this->method);
     return $this;
 }
Example #13
0
 function saveClientExtras($argArrPost)
 {
     $objCore = new Core();
     $clientExtra1 = $argArrPost['ClientExtra1'];
     $clientExtra2 = $argArrPost['ClientExtra2'];
     if ($argArrPost['client_id'] != '') {
         $varWhere = 'pkClientID = ' . $argArrPost['client_id'];
         $arrclm = array('ClientExtra1' => $clientExtra1, 'ClientExtra2' => $clientExtra2);
         $varExtraID = $this->update(TABLE_CLIENTS, $arrclm, $varWhere);
         $objCore->setSuccessMsg("Extra settings updated successfully");
         return 2;
     }
 }
Example #14
0
 public function render($output)
 {
     $Core = new Core();
     $this->dir = $_SERVER['DOCUMENT_ROOT'] . DS . $Core->path;
     //print_r($this->values);
     if (isset($this->values['layout'])) {
         $this->layout = $this->values['layout'];
     }
     $base_url = $Core->site($this->layout);
     $site_url = $Core->site_url();
     $title = isset($this->values['title']) ? $this->values['title'] : $this->title;
     $header = isset($this->values['header']) ? $this->values['header'] : $this->header;
     $content = $output;
     include $this->dir . DS . 'Layout' . DS . $this->layout . DS . 'default.phtml';
 }
Example #15
0
 /**
  * Add the comment.
  */
 function execute()
 {
     // Personalized execute() method since now there are possibly two comments contained within each form submission.
     $commentDao = DAORegistry::getDAO('PaperCommentDAO');
     $this->insertedComments = array();
     // Assign all common information
     $comment = new PaperComment();
     $comment->setCommentType($this->commentType);
     $comment->setRoleId($this->roleId);
     $comment->setPaperId($this->paper->getPaperId());
     $comment->setAssocId($this->assocId);
     $comment->setAuthorId($this->user->getId());
     $comment->setCommentTitle($this->getData('commentTitle'));
     $comment->setDatePosted(Core::getCurrentDate());
     // If comments "For authors and director" submitted
     if ($this->getData('authorComments') != null) {
         $comment->setComments($this->getData('authorComments'));
         $comment->setViewable(1);
         array_push($this->insertedComments, $commentDao->insertPaperComment($comment));
     }
     // If comments "For director" submitted
     if ($this->getData('comments') != null) {
         $comment->setComments($this->getData('comments'));
         $comment->setViewable(null);
         array_push($this->insertedComments, $commentDao->insertPaperComment($comment));
     }
 }
 /**
  * View an assigned submission's layout editing page.
  * @param $args array ($articleId)
  */
 function submission($args)
 {
     $articleId = isset($args[0]) ? $args[0] : 0;
     list($journal, $submission) = SubmissionLayoutHandler::validate($articleId);
     parent::setupTemplate(true, $articleId);
     import('submission.proofreader.ProofreaderAction');
     ProofreaderAction::layoutEditorProofreadingUnderway($submission);
     $layoutAssignment =& $submission->getLayoutAssignment();
     if ($layoutAssignment->getDateNotified() != null && $layoutAssignment->getDateUnderway() == null) {
         // Set underway date
         $layoutAssignment->setDateUnderway(Core::getCurrentDate());
         $layoutDao =& DAORegistry::getDAO('LayoutEditorSubmissionDAO');
         $layoutDao->updateSubmission($submission);
     }
     $disableEdit = !SubmissionLayoutHandler::layoutEditingEnabled($submission);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign_by_ref('submission', $submission);
     $templateMgr->assign('disableEdit', $disableEdit);
     $templateMgr->assign('useProofreaders', $journal->getSetting('useProofreaders'));
     $templateMgr->assign('templates', $journal->getSetting('templates'));
     $templateMgr->assign('helpTopicId', 'editorial.layoutEditorsRole.layout');
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($submission->getArticleId());
     if ($publishedArticle) {
         $issueDao =& DAORegistry::getDAO('IssueDAO');
         $issue =& $issueDao->getIssueById($publishedArticle->getIssueId());
         $templateMgr->assign_by_ref('publishedArticle', $publishedArticle);
         $templateMgr->assign_by_ref('issue', $issue);
     }
     $templateMgr->display('layoutEditor/submission.tpl');
 }
Example #17
0
 /**
  * (non-PHPdoc)
  * @see BPCPageAbstract::onLoad()
  */
 public function onLoad($param)
 {
     parent::onLoad($param);
     if (!AccessControl::canAccessPriceMatchPage(Core::getRole())) {
         die(BPCPageAbstract::show404Page('Access Denied', 'You do NOT have the access to this page!'));
     }
 }
Example #18
0
 public function rescan_locale()
 {
     if ($this->token->validate('rescan_locale')) {
         $u = new \User();
         if ($u->isSuperUser()) {
             \Core::make('cache/request')->disable();
             $section = Section::getByID($_REQUEST['locale']);
             $target = new MultilingualProcessorTarget($section);
             $processor = new Processor($target);
             if ($_POST['process']) {
                 foreach ($processor->receive() as $task) {
                     $processor->execute($task);
                 }
                 $obj = new \stdClass();
                 $obj->totalItems = $processor->getTotalTasks();
                 echo json_encode($obj);
                 exit;
             } else {
                 $processor->process();
             }
             $totalItems = $processor->getTotalTasks();
             \View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d task", "%d tasks", $totalItems)));
             exit;
         }
     }
 }
Example #19
0
 /**
  * @return Community
  */
 public function getService()
 {
     if (!$this->service) {
         $this->service = \Core::make('authentication/community');
     }
     return $this->service;
 }
Example #20
0
	/**
	 * Test that a message can be written to a log file.
	 *
	 * @return \Core\Utilities\Logger\LogFile The log file created.
	 */
	public function testWrite(){
		$type = 'testphpunit';
		$msg  = \BaconIpsumGenerator::Make_a_Sentence();
		$code = '/test/' . Core::RandomHex(6);

		// First, I'll test the functional method.
		\Core\Utilities\Logger\append_to($type, $msg, $code);

		// Now a file should exist called testphpunit.log that contains the line above.
		$this->assertTrue(file_exists(ROOT_PDIR . 'logs/' . $type . '.log'));
		$contents = file_get_contents(ROOT_PDIR . 'logs/' . $type . '.log');
		$this->assertContains($msg, $contents);
		$this->assertContains($code, $contents);

		// And now the class method, (should be identical).
		$type = 'testphpunit';
		$msg  = \BaconIpsumGenerator::Make_a_Sentence();
		$code = '/test/' . Core::RandomHex(6);

		// First, I'll test the functional method.
		$log = new \Core\Utilities\Logger\LogFile($type);
		$log->write($msg, $code);

		// Now a file should exist called testphpunit.log that contains the line above.
		$this->assertTrue($log->exists());
		$contents = $log->getContents();
		$this->assertContains($msg, $contents);
		$this->assertContains($code, $contents);

		return $log;
	}
Example #21
0
 /**
  * autoload
  *
  * This function automatically loads any missing classes as they are
  * needed so that we don't use a million include statements which load
  * more than we need.
  */
 public static function autoload($class)
 {
     if (strpos($class, '\\') === false) {
         $file = AmpConfig::get('prefix') . '/lib/class/' . strtolower($class) . '.class.php';
         if (Core::is_readable($file)) {
             require_once $file;
             // Call _auto_init if it exists
             $autocall = array($class, '_auto_init');
             if (is_callable($autocall)) {
                 call_user_func($autocall);
             }
         } else {
             debug_event('autoload', "'{$class}' not found!", 1);
         }
     } else {
         // Class with namespace are not used by Ampache but probably by modules
         $split = explode('\\', $class);
         $path = AmpConfig::get('prefix') . '/modules';
         for ($i = 0; $i < count($split); ++$i) {
             $path .= '/' . $split[$i];
             if ($i != count($split) - 1) {
                 if (!is_dir($path)) {
                     break;
                 }
             } else {
                 $path .= '.php';
                 if (Core::is_readable($path)) {
                     require_once $path;
                 }
             }
         }
     }
 }
Example #22
0
 /**
  * generates HTML for apy buton
  * @param  Model_Order $order 
  * @return string                 
  */
 public static function button(Model_Order $order)
 {
     if (Core::config('payment.paymill_private') != '' and Core::config('payment.paymill_public') != '' and Theme::get('premium') == 1 and $order->loaded()) {
         return View::factory('pages/paymill/button', array('order' => $order));
     }
     return '';
 }
Example #23
0
 public static function doJob($job)
 {
     $db = Core::GetDBInstance(null, true);
     $messageSerializer = new Scalr_Messaging_XmlSerializer();
     $message = $db->GetRow("SELECT server_id, message, id, handle_attempts FROM messages WHERE id=?", array($job->workload()));
     try {
         if ($message['handle_attempts'] >= 3) {
             $db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::FAILED, $message['id']));
         } else {
             try {
                 $DBServer = DBServer::LoadByID($message['server_id']);
             } catch (Exception $e) {
                 $db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::FAILED, $message['id']));
                 return;
             }
             if ($DBServer->status == SERVER_STATUS::RUNNING || $DBServer->status == SERVER_STATUS::INIT || $DBServer->status == SERVER_STATUS::IMPORTING || $DBServer->status == SERVER_STATUS::TEMPORARY || $DBServer->status == SERVER_STATUS::PENDING_TERMINATE) {
                 // Only 0.2-68 or greater version support this feature.
                 if ($DBServer->IsSupported("0.2-68")) {
                     $msg = $messageSerializer->unserialize($message['message']);
                     $DBServer->SendMessage($msg);
                 } else {
                     $db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::UNSUPPORTED, $message['id']));
                 }
             } elseif (in_array($DBServer->status, array(SERVER_STATUS::TERMINATED, SERVER_STATUS::PENDING_TERMINATE))) {
                 $db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::FAILED, $message['id']));
             }
         }
     } catch (Exception $e) {
         //var_dump($e->getMessage());
     }
 }
Example #24
0
 public function attach($owner)
 {
     if (Core::app()->checkInstalledModule($this->module_alias)) {
         parent::attach($owner);
         return true;
     }
 }
Example #25
0
 /**
  * constructor
  */
 public function __construct()
 {
     parent::__construct();
     if (!AccessControl::canAccessProductsPage(Core::getRole())) {
         die('You do NOT have access to this page');
     }
 }
Example #26
0
 public function updateAction()
 {
     $criteria = new Criteria("person");
     $person = PersonData::getById($_POST["id"]);
     $criteria->update(array("no" => "\"{$_POST['no']}\"", "name" => "\"{$_POST['name']}\"", "lastname" => "\"{$_POST['lastname']}\"", "job" => "\"{$_POST['job']}\"", "phone1" => "\"{$_POST['phone1']}\"", "phone2" => "\"{$_POST['phone2']}\"", "address1" => "\"{$_POST['address1']}\"", "address2" => "\"{$_POST['address2']}\"", "email1" => "\"{$_POST['email1']}\"", "email2" => "\"{$_POST['email2']}\"", "team_id" => "\"{$_POST['team_id']}\"", "category_id" => "\"{$_POST['category_id']}\""), "id=" . $_POST["id"]);
     Core::redir("./?r=index/people");
 }
Example #27
0
 /**
  * Set the value of a form field.
  * @param $key
  * @param $value
  */
 function setData($key, $value)
 {
     if (is_string($value)) {
         $value = Core::cleanVar($value);
     }
     $this->_data[$key] = $value;
 }
Example #28
0
 /**
  * Redeem a gift for a user.
  * @param $assocType int
  * @param $assocId int
  * @param $userId int
  * @param $giftId int
  * @return int Status code indicating whether gift could be redeemed
  */
 function redeemGift($assocType, $assocId, $userId, $giftId)
 {
     // Ensure user has this gift
     if (!$this->recipientHasGift($assocType, $assocId, $userId, $giftId)) {
         return GIFT_REDEEM_STATUS_ERROR_NO_GIFT_TO_REDEEM;
     }
     // Ensure user has not already redeemed this gift
     if (!$this->recipientHasNotRedeemedGift($assocType, $assocId, $userId, $giftId)) {
         return GIFT_REDEEM_STATUS_ERROR_GIFT_ALREADY_REDEEMED;
     }
     // Retrieve and try to redeem the gift
     $gift = $this->getGift($giftId);
     switch ($gift->getGiftType()) {
         case GIFT_TYPE_SUBSCRIPTION:
             $returner = $this->_redeemGiftSubscription($gift);
             break;
         default:
             $returner = GIFT_REDEEM_STATUS_ERROR_GIFT_INVALID;
     }
     // If all went well, mark gift as redeemed
     if ($returner == GIFT_REDEEM_STATUS_SUCCESS) {
         $gift->setStatus(GIFT_STATUS_REDEEMED);
         $gift->setDatetimeRedeemed(Core::getCurrentDate());
         $this->updateObject($gift);
     }
     return $returner;
 }
Example #29
0
 /**
  * Upload a profile image.
  * @return boolean True iff success.
  */
 function uploadProfileImage()
 {
     import('classes.file.PublicFileManager');
     $publicFileManager = new PublicFileManager();
     $user = $this->getUser();
     $type = $publicFileManager->getUploadedFileType('uploadedFile');
     $extension = $publicFileManager->getImageExtension($type);
     if (!$extension) {
         return false;
     }
     $uploadName = 'profileImage-' . (int) $user->getId() . $extension;
     if (!$publicFileManager->uploadSiteFile('uploadedFile', $uploadName)) {
         return false;
     }
     $filePath = $publicFileManager->getSiteFilesPath();
     list($width, $height) = getimagesize($filePath . '/' . $uploadName);
     if ($width > PROFILE_IMAGE_MAX_WIDTH || $height > PROFILE_IMAGE_MAX_HEIGHT || $width <= 0 || $height <= 0) {
         $userSetting = null;
         $user->updateSetting('profileImage', $userSetting);
         $publicFileManager->removeSiteFile($filePath);
         return false;
     }
     $user->updateSetting('profileImage', array('name' => $publicFileManager->getUploadedFileName('uploadedFile'), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'dateUploaded' => Core::getCurrentDate()));
     return true;
 }
Example #30
0
 public function getPermissionKeyByID($pkID)
 {
     $txt = Loader::helper('text');
     $className = core_class('\\Core\\Permission\\Key\\' . \Core::make("helper/text")->camelcase($this->pkCategoryHandle) . 'Key', $this->getPackageHandle());
     $ak = call_user_func(array($className, 'getByID'), $pkID);
     return $ak;
 }