コード例 #1
0
ファイル: Facade.class.php プロジェクト: evilgeny/bob
 public function loadById($id)
 {
     if (isNull($object = $this->_mapper->storage()->loadObjectById($id))) {
         return $this->_mapper->getDefaultGroup();
     }
     return $object;
 }
コード例 #2
0
ファイル: 4.export.php プロジェクト: evilgeny/bob
function transfer()
{
    $query = M('Db')->createQuery('tmp_equipment_export')->what('city_id, user_id, scaner_id, modem_id, laptop_id')->where('`exit` IS NULL OR `exit` = ""');
    $request = M('Store')->requestQuery(M('Store')->factoryObject(), $query);
    $transfer = 0;
    foreach ($request as $object) {
        if (!isNull($obHolder = getHolderByUserId($object->user_id))) {
            if (!isNull($obEquipment = M('Equipment')->loadById($object->scaner_id))) {
                if ($obEquipment->holder_id != $obHolder->id) {
                    $obEquipment->setHolder($obHolder);
                    $obEquipment->save();
                    $transfer++;
                }
            }
            if (!isNull($obEquipment = M('Equipment')->loadById($object->modem_id))) {
                if ($obEquipment->holder_id != $obHolder->id) {
                    $obEquipment->setHolder($obHolder);
                    $obEquipment->save();
                    $transfer++;
                }
            }
            if (!isNull($obEquipment = M('Equipment')->loadById($object->laptop_id))) {
                if ($obEquipment->holder_id != $obHolder->id) {
                    $obEquipment->setHolder($obHolder);
                    $obEquipment->save();
                    $transfer++;
                }
            }
        }
    }
    echo "\n\nTRANSFER: {$transfer} enities";
}
コード例 #3
0
ファイル: Classify.class.php プロジェクト: evilgeny/bob
 protected function _list()
 {
     if (isNull($this->_list)) {
         $this->_list = M('List')->loadById($this->_list_id);
     }
     return $this->_list;
 }
コード例 #4
0
ファイル: tools.php プロジェクト: evilgeny/bob
/**
 *	Returns logged user or anonymous user.
 *
 *	@return		RM_Account_iUser
 */
function me()
{
    if (isNull($result = M('Account')->getLoggedUser())) {
        $result = M('Account')->getAnonymousUser();
    }
    return $result;
}
コード例 #5
0
ファイル: Ok.class.php プロジェクト: evilgeny/bob
 protected function _isAddToModeration()
 {
     $barcode = $this->_object->getBarcode();
     if (!M('Purchase')->isInStopList($this->_object->barcode_value) && (isNull($barcode = $this->_object->getBarcode()) || $barcode->attribute_1 != $this->_object->corrected_name)) {
         return TRUE;
     }
 }
コード例 #6
0
ファイル: anomalytree.php プロジェクト: sdesimone/bigml-php
 function depth($input_data, $path = null, $depth = 0)
 {
     /*
      Returns the depth of the node that reaches the input data instance
      when ran through the tree, and the associated set of rules.
     
      If a node has any children whose
      predicates are all true given the instance, then the instance will
      flow through that child.  If the node has no children or no
      children with all valid predicates, then it outputs the depth of the
      node.
     */
     if (isNull($path)) {
         $path = array();
     }
     # root node: if predicates are met, depth becomes 1, otherwise is 0
     if ($depth == 0) {
         if (!$this->predicates->apply($input_data, $this->fields)) {
             return array($depth, $path);
         }
         $depth += 1;
     }
     if ($this->children != null) {
         foreach ($this->children as $child) {
             if ($child->predicates->apply($input_data, $this->fields)) {
                 $array_push($path, $child->predicates->to_rule($this->fields));
                 return $child->depth($input_data, $path, $depth + 1);
             }
         }
     }
     return array($depth, $path);
 }
コード例 #7
0
ファイル: Facade.class.php プロジェクト: evilgeny/bob
 public function loadCategoryByName($name)
 {
     if (!isNull($object = $this->_mapper->loadCategoryByName($name))) {
         $this->_mapper->access($object, 'CATEGORY.USE');
     }
     return $object;
 }
コード例 #8
0
ファイル: Facade.class.php プロジェクト: evilgeny/bob
 public function getCaptionByVarname($name)
 {
     if (!isNull($value = $this->loadObjectByName($name))) {
         return $value->getCaption();
     }
     return L('list.value.' . $name);
 }
コード例 #9
0
ファイル: Facade.class.php プロジェクト: evilgeny/bob
 /**
  *	Description...
  *
  *	@return void
  **/
 public function loadReportById($id)
 {
     if (!isNull($object = $this->_mapper->storage('total')->loadObjectById($id))) {
         $this->_mapper->access($object, 'READ');
     }
     return $object;
 }
コード例 #10
0
ファイル: Diagram.class.php プロジェクト: evilgeny/bob
 /**
  * Enter description here...
  *
  * @return RM_Diagram_Object
  */
 protected function get()
 {
     if (!$this->_diagram && isNull($this->_diagram = M('Diagram')->loadDiagramByName($this->_name))) {
         $this->create();
     }
     return $this->_diagram;
 }
コード例 #11
0
ファイル: Kpi.class.php プロジェクト: evilgeny/bob
 public function getDiagramList()
 {
     $obData = $this->getData();
     $obData->setColumnsForRowDescribe();
     $obData->hideColumns(REPDATA_ALL);
     $obData->setSharedParams($this->_object->detail()->getFieldNameWithName());
     $diagrams = array();
     foreach ($this->_object->getValues() as $obValue) {
         if (isNull($obDiagram = M('Diagram')->loadDiagramByName($this->getDiagramName($obValue)))) {
             $obData->hideColumns(REPDATA_ALL);
             $obData->showColumns($obValue->getVarname());
             $obDiagram = $this->advancedKpiStrategy()->createDiagramByData($obData, $obValue);
             $obDiagram->setPermissionLikeObject($this->_object);
             $obDiagram->rowCaptionVariable($this->_object->detail()->getFieldNameWithName());
             $obDiagram->yLabelsCallbackFunction(array($obValue, 'callbackForPlotAxis'));
             $obDiagram->xLabelsCallbackFunction(array($this->_object->period(), 'getCaptionBySystemValue'));
             $obDiagram->prepareFunction(array($obValue, 'callbackForPlot'));
             $obDiagram->setAxisCaption(array($obValue, 'getAxisCaption'));
             $obDiagram->draw();
             $obDiagram->save();
         }
         $diagrams[] = $obDiagram;
     }
     return $diagrams;
 }
コード例 #12
0
ファイル: Log.class.php プロジェクト: evilgeny/bob
 public function getUserString($obUser, $description = 'user')
 {
     $add_str = " (";
     $add_str .= !isNull($obUser->getCity()) ? $obUser->getCity()->name : "Unknown City";
     $add_str .= ")";
     return $description . "=" . $obUser->id() . " " . $obUser->getAddressTo() . $add_str;
 }
コード例 #13
0
ファイル: shortcuts.php プロジェクト: evilgeny/bob
/**
 * install template type
 * @param string name	: template type name
 * @param string description	: description for template type
 * @param array	variables	: type variables with description
 * 		Example:
 *					  	array(
 *											"nick"			=> "User nick",
 *											"email"			=> "User email (use as login)",
 *											"password"	=> "User password",
 *											"login"			=> "User login",
 *										);
 * @param array templates :	array of templates params
 * 		Example:
 *	 	 	$ar = array();
 *
 *	 	 	$ar[] = array(
 *				"lang"		=> "rus",
 *				"file_path" => "/rus/user/",
 *				"file_name" => "new.php",
 *			);
 *
 *			$ar[] = array(
 *				"lang"		=> "eng",
 *				"file_path" => "/eng/user/",
 *				"file_name" => "new.php",
 *			);
 *
 *
 * @return	void
 */
function installTemplateType($name, $description, array $variables, array $templates)
{
    if (!isNull($obType = M("MailTemplate")->loadTypeById($name))) {
        $obType->delete();
    }
    $obType = M("MailTemplate")->createType($name);
    $obType->description = $description;
    $obType->save();
    if (!isNull($obType)) {
        foreach ($variables as $k => $v) {
            // create variable object
            $ob = $obType->createVariable($k);
            // init variable properties
            $ob->description = $v;
            // save variable
            if (!$ob->save()) {
                print_r($ob->validator()->getErrors());
            }
        }
    }
    if (!isNull($obType)) {
        foreach ($templates as $v) {
            // create template object
            $ob = $obType->createTemplate();
            // init template object properties
            foreach ($v as $k => $s) {
                $ob->{$k} = $s;
            }
            // save template object
            if (!$ob->save()) {
                print_r($ob->validator()->getErrors());
            }
        }
    }
}
コード例 #14
0
 public static function getInstance()
 {
     if (isNull(static::$instance)) {
         static::$instance = new static();
     }
     return static::$instance;
 }
コード例 #15
0
 protected function validateContainerName($container)
 {
     if (isNull($this->helper)) {
         $this->helper = new ContainerHelper();
     }
     return $this->helper->containerExists($container);
 }
コード例 #16
0
ファイル: Event.class.php プロジェクト: evilgeny/bob
 /**
  * Returns user's account by user id
  *
  * @param 	int $userId
  * @return	RM_Points_Account
  */
 public function getAccount($userId)
 {
     if (isNull($obUser = M('User')->loadUserById($userId))) {
         throw new RM_Base_Exception_Internal("Unable to load user by id: `{$userId}'");
     }
     return $this->_mapper->loadAccountByUserOrCreate($obUser);
 }
コード例 #17
0
ファイル: Main.class.php プロジェクト: evilgeny/bob
 public function addFlavoursToBarcode(RM_Barcode_Object $obBarcode, $flavour_names, $flavour_type, &$error)
 {
     $result = FALSE;
     if ($flavour_names) {
         if (!in_array($flavour_type, M('Gpc')->flavour_types())) {
             $error = 'gpc.wrong_flavour_type';
         } else {
             foreach ($obBarcode->getFlavours() as $obFlavour) {
                 $obFlavour->removeBarcode($obBarcode, $flavour_type);
             }
             foreach ($flavour_names as $flavour_name) {
                 if (!trim($flavour_name)) {
                     continue;
                 }
                 if (isNull($obFlavour = M('Gpc')->loadFlavourByName(trim($flavour_name)))) {
                     $error = 'gpc.no_such_flavours';
                 } else {
                     $obFlavour->addBarcode($obBarcode, $flavour_type);
                     $result = TRUE;
                 }
             }
         }
     }
     return $result;
 }
コード例 #18
0
ファイル: Facade.class.php プロジェクト: evilgeny/bob
 /**
  * Returns admin note object
  *
  * @param 	array					data
  * @param 	RM_Account_iUser		obWriter
  * @return 	RM_AdminNote_Object
  */
 public function createNote($data = array(), RM_Account_iUser $obWriter)
 {
     if (!@$data['type'] && !@$data['type_no_action'] && !@$data['body']) {
         $res = new RM_Base_Result();
         $res->error('at_least_one_field');
         throw new RM_Validator_Exception($res);
     }
     if (isNull($obUser = M('User')->loadUserById(@$data['user_id']))) {
         $res = new RM_Base_Result();
         $res->error('no_such_user');
         throw new RM_Validator_Exception($res);
     }
     $arr = array();
     $arr['writer_id'] = $obWriter->id();
     $arr['user_id'] = $obUser->id();
     if (@$data['type']) {
         $arr['type'] = (int) $data['type'];
     }
     if (@$data['type_no_action']) {
         $arr['type_no_action'] = (int) $data['type_no_action'];
     }
     if (@$data['body']) {
         $arr['body'] = $data['body'];
     }
     //$arr['is_done'] = 1;
     $arr['posted'] = M('Tools')->date()->dbDateTime();
     return $this->_mapper->_storage('adminNote')->createObject($arr);
 }
コード例 #19
0
ファイル: Downtime.class.php プロジェクト: evilgeny/bob
 /**
  * Returns shop
  *
  * @return	RM_Shop_Object
  */
 protected function object()
 {
     if (isNull($this->_shop)) {
         $this->_shop = $this->_mapper->loadShopById($this->shop_id);
     }
     return $this->_shop;
 }
コード例 #20
0
ファイル: OrderControl.class.php プロジェクト: evilgeny/bob
 /**
  * Enter description here...
  *
  * @return RM_Db_Query
  */
 protected function _reportQuery()
 {
     if (isNull($this->_query)) {
         $this->_query = $query;
     }
     return $this->_query;
 }
コード例 #21
0
ファイル: Bar.class.php プロジェクト: evilgeny/bob
 /**
  *	Description...
  *
  *	@return void
  **/
 public function graph()
 {
     if (isNull($this->_graph)) {
         $this->_graph = $this->_plot->graph();
     }
     return $this->_graph;
 }
コード例 #22
0
ファイル: Calc.class.php プロジェクト: evilgeny/bob
 protected function _composite()
 {
     if (isNull($this->_composite)) {
         $this->_composite = M('ReportScript')->createCompositeCommand();
     }
     return $this->_composite;
 }
コード例 #23
0
ファイル: Item.class.php プロジェクト: evilgeny/bob
 /**
  * Enter description here...
  *
  * @param 	string 	$name
  * @return 	RM_Holder_Invoice_Item_State
  */
 protected function _state($name = NULL, $data = array())
 {
     if (!isNull($name) || isNull($this->_state)) {
         $class = 'RM_Holder_Invoice_Item_State_' . ucfirst(isNull($name) ? $this->invoice_state : $name);
         $this->_state = new $class($this, $data);
     }
     return $this->_state;
 }
コード例 #24
0
ファイル: Unique.class.php プロジェクト: evilgeny/bob
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (!isNull(iterFirst(M('Category')->getCategoryList()->filter('name=? and id!=?', $data[$field], $data['id'])))) {
         $result->error('name_not_unique', $field);
         return FALSE;
     }
     return TRUE;
 }
コード例 #25
0
ファイル: Company.class.php プロジェクト: evilgeny/bob
 /**
  *	Description...
  *
  *	@return void
  **/
 public function valueSelected($name)
 {
     #!! Need to be refactored!
     if (isNull($obValue = M('ReportValue')->loadObjectByName($name)) || isNull($this->getCompanyGroup())) {
         return FALSE;
     }
     return $obValue->checkGroupPermission($this->getCompanyGroup());
 }
コード例 #26
0
ファイル: CompanyUnique.class.php プロジェクト: evilgeny/bob
 /**
  * Check Email not exists in ssp registration (AuthServer)
  *
  * @param      array			$data               Array with values
  * @param      string     $field          Field to check
  * @param      RM_Base_iResult          Errors and warnngs stack
  * @return     void
  */
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (!isNull($company = M('Client')->loadCompanyByName($data[$field])) && $company->id() != $data['id']) {
         $result->error('company_name_unique', $field);
         return false;
     }
     return true;
 }
コード例 #27
0
 /**
  * Check Email not exists in ssp registration (AuthServer)
  *
  * @param      array			$data               Array with values
  * @param      string     $field          Field to check
  * @param      RM_Base_iResult          Errors and warnngs stack
  * @return     void
  */
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (!isNull($user = M('Client')->loadUserBySslNumber($data[$field])) && $user->id() != $data['id']) {
         $result->error('client_ssl_unique', $field);
         return false;
     }
     return true;
 }
コード例 #28
0
ファイル: EmailUnique.class.php プロジェクト: evilgeny/bob
 /**
  * Check Email not exists in SSP
  *
  * @param		array		$data		Array with values
  * @param		string		$field		Field to check
  * @param		RM_Base_iResult			Errors and warnngs stack
  * @return		void
  */
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (!isNull(M('User')->loadUserByLogin($data[$field]))) {
         $result->error('email_unique', $field);
         return false;
     }
     return true;
 }
コード例 #29
0
ファイル: NameUnique.class.php プロジェクト: evilgeny/bob
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (!isNull($script = M('ReportScript')->loadScriptByName($data[$field])) && $script->id() != $data['id']) {
         $result->error('script_name_not_unique', $field);
         return FALSE;
     }
     return TRUE;
 }
コード例 #30
0
ファイル: ReceiptDelete.class.php プロジェクト: evilgeny/bob
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (isNull($obReceipt = M('Purchase')->receipt()->loadVirtualById($data['id'])) || count($obReceipt->getPurchases())) {
         $result->error('delete_not_empty_receipt', $field);
         return FALSE;
     }
     return TRUE;
 }