Exemplo n.º 1
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     return $args;
 }
Exemplo n.º 2
0
 public function delete(RM_User_Leave $obLeave)
 {
     if (!$this->canDelete($obLeave)) {
         error(L('leave.cannot_delete_leave_expired'));
         return FALSE;
     }
     // update leave if current
     if ($obLeave->isStatus('current') && !me()->isSomeAdmin() && M('Date')->time($obLeave->date_from) < M('Date')->time(M('Tools')->date()->dbDate())) {
         /*			$prev_day = iterFirst(M('Db')->query('SELECT DATE(DATE_SUB(NOW(), INTERVAL 1 DAY)) AS prev_day'));
         			$prev_day = $prev_day['prev_day'];
         			$date_to = (strtotime($prev_day) >= strtotime($obLeave->date_from)) ? $prev_day : M('Tools')->date()->dbDate();
         			if ( MC('Leave')->update($obLeave, array('date_to' => $date_to)) )
         				message(L('leave.leave_updated_not_deleted'));
         			return FALSE;*/
         if ($this->dropDateToCurrent($obLeave)) {
             message(L('leave.leave_updated_not_deleted'));
         }
         return FALSE;
     }
     // delete leave
     if ($obLeave->delete()) {
         M('Points')->leaveRemoved($obLeave);
         return TRUE;
     }
     return FALSE;
 }
Exemplo n.º 3
0
 public function save()
 {
     if (!$this->type_id) {
         $this->type_id = 11;
     }
     if (!$this->name) {
         $this->name = L('shop.empty_name');
     }
     if (!$this->city_id && me()->id()) {
         $this->city_id = me()->city_id;
     }
     if (!($this->longitude + 0)) {
         $this->longitude = NULL;
     }
     if (!($this->latitude + 0)) {
         $this->latitude = NULL;
     }
     /*foreach ($this->links() as $link)
     		{
     			$link->shop_type=$this->type_id;
     			$link->name=$this->name;
     			$link->save();
     		}*/
     $this->mdate = M('Date')->dbDateTime();
     if (!$this->cdate) {
         $this->cdate = M('Date')->dbDateTime();
     }
     return parent::save();
 }
Exemplo n.º 4
0
 public function createGroup($name)
 {
     $object = $this->_storage->loadOrCreateObject('name', $name, array('name' => $name, 'owner_id' => -1));
     M('Permission')->changePermission($object, array(array('grant', me()->getPersonalGroup()->id(), 'READ')));
     $object->save();
     return $object;
 }
Exemplo n.º 5
0
 public function __construct()
 {
     if (!MC('User')->checkAccessToEditGpc(me())) {
         goU('main');
     }
     $this->_action_list = array('rename' => L('wizard.gpc_rename_attribute_action'), 'edit' => L('wizard.gpc_edit_attribute_action'), 'add' => L('wizard.gpc_add_attribute_action'), 'delete' => L('wizard.gpc_delete_attribute_action'));
 }
Exemplo n.º 6
0
 /**
  * @see RM_Store_Object::save()
  */
 public function save()
 {
     if (!$this->_existsInDb()) {
         $this->_mapper->access($this, 'CATEGORY.CREATE');
     }
     if (!$this->owner_id) {
         $this->owner_id = -1;
     }
     if (!$this->generaltype_id && $this->name) {
         $this->generaltype_id = M('Guid')->get(G('generaltype-fake'));
     }
     if (!$this->cdate) {
         $this->cdate = M('Date')->dbDateTime();
     }
     $mask = array();
     foreach ($this->_props as $name => $value) {
         if ($value != $this->_propInitial($name)) {
             $mask = $this->_mapper->_getCheckMaskArray($name);
         }
     }
     $this->changed_by = me()->id();
     if ($mask) {
         $this->_mapper->access($this, join('|', $mask));
     }
     $this->mdate = M('Date')->dbDateTime();
     return parent::save();
 }
Exemplo n.º 7
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['query'] = M('Points')->getPointsReportQuery(@$_GET['user_id'] ? $_GET['user_id'] : me()->id());
     if (!me()->isUserInGroup(array('admin', 'region-admin', 'super-admin'), FALSE)) {
         $args['no_visible'][] = 'cdate';
     }
     return $args;
 }
Exemplo n.º 8
0
function restrict()
{
    if (!me()) {
        header("HTTP/1.1 403 Forbidden");
        header("Location: index.php");
        exit;
    }
}
Exemplo n.º 9
0
 /**
  * Init holder if need.
  *
  * @return void
  */
 protected function _initHolder()
 {
     if (isNull($this->_data['obHolder'])) {
         if (isNull($this->_data['obHolder'] = M('Holder')->getRegionHolderByUser(me()))) {
             throw new RM_Base_Exception_Internal(__METHOD__ . ': can\'t find open region holder');
         }
     }
 }
Exemplo n.º 10
0
 /**
  * Enter description here...
  *
  */
 public function save()
 {
     if (!$this->_obReceipt->cdate_real) {
         $this->_obReceipt->cdate_real = M('Date')->dbDateTime();
     }
     $this->_obReceipt->checker_id = me()->id();
     parent::save();
 }
Exemplo n.º 11
0
 public function getAdditionalParams($args)
 {
     if (!me()->isUserInGroup('federal-news')) {
         $args['restriction']['city_id = ?'] = me()->city_id;
         $args['no_visible'][] = 'city_id';
     }
     return $args;
 }
Exemplo n.º 12
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['aliases'] = array('type_id' => 's.type_id', 'city_id' => 's.city_id', 'shop_count' => 'COUNT(*)');
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     $args['query'] = M('Shop')->getAggregateShopTypeQuery();
     return $args;
 }
 public function doAdd($user_id)
 {
     if (!me()->hasPermissionTo('add', 'Recommendation')) {
         err('You don\'t have permission to leave a recommendation for that user.');
         return Redirect::to(URL::previous());
     }
     $recommendation = new Recommendation();
     return $recommendation->validateAndUpdateFromArray(Input::all());
 }
Exemplo n.º 14
0
 /**
  * Enter description here...
  *
  * @param hash$args
  * @return hash
  */
 public function getAdditionalParams($args)
 {
     $args['query'] = M('Presents')->getOrdersControlReportQuery();
     $args['aliases'] = array('city_id' => 'u.city_id', 'user_id' => 'r.user_id', 'present_id' => 'p.name', 'price' => 'r.price', 'quantity' => 'r.quantity', 'state' => 'r.state', 'cdate' => 'r.cdate', 'mdate' => 'r.mdate');
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     return $args;
 }
Exemplo n.º 15
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['aliases'] = array('event_date' => 'ud.event_date', 'result_id' => 'ud.result_id', 'user_id' => 'ud.user_id', 'city_id' => 'u.city_id');
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     $args['query'] = M('User')->report()->getActivityReportQuery()->order('event_date desc');
     return $args;
 }
Exemplo n.º 16
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['aliases'] = qw2('uid>r.user_id bdate>r.bdate number>r.number total_virt>r.total_virt total_real>r.total_real diff>diff vpurchase_count>vpurchase_count city_id>u.city_id');
     $args['having'] = array('diff' => 'ROUND( IFNULL(r.total_virt*(1-IFNULL(r.discount_virt,0)),0) - IFNULL(r.total_real*(1-IFNULL(r.discount_real,0)),0), 2)', 'vpurchase_count' => 'SUM( IF(p.is_deleted != 1 AND p.status_id = 3, 1, 0) )');
     $args['query'] = M('Purchase')->report()->getReportQueryReceiptListControl();
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     return $args;
 }
Exemplo n.º 17
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['query'] = M('Holder')->getHolderReportQuery();
     // implemenst permissions check
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     $args['edit_target'] = '_self';
     return $args;
 }
Exemplo n.º 18
0
 /**
  *	Description...
  *
  *	@return void
  **/
 public function createTotal($type = NULL)
 {
     $report = $this->_mapper->storage('total')->createObject(qw2("report_type>{$type} owner_id>" . me()->id()));
     $permissions[] = array('grant', PERM_TARGET_OWNER, 'ALL');
     foreach (me()->getUserGroups() as $group) {
         $permissions[] = array('grant', $group->id(), 'READ');
     }
     M('Permission')->changePermission($report, $permissions);
     return $report;
 }
Exemplo n.º 19
0
	function get_random_id($upload) {
		$pickuplinks = PickupLink::get();

		$filter = me()->getPref("hide_nsfw") ? " AND nsfw = 0" : "";
		$filter .= me()->getPref("hide_tmbo") ? " AND tmbo = 0" : "";
		$sql = "SELECT id FROM offensive_uploads WHERE type='".$upload->type()."' AND status='normal' AND id < ".min($pickuplinks).$filter." ORDER BY RAND() LIMIT 1";
		$res = tmbo_query($sql);
		$row = mysql_fetch_assoc( $res );
		return($row['id']);
	}
Exemplo n.º 20
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['aliases'] = qw2('user_id>u.user_id status>s.name receipt_virt>receipt_virt receipt_real>receipt_real receipt_diff>receipt_diff city_id>u.city_id');
     $args['having'] = array('receipt_virt' => 'SUM(IF(r.bit_mask & 2,1,0))', 'receipt_real' => 'SUM(IF(r.bit_mask & 1,1,0))', 'receipt_diff' => 'SUM(IF(r.bit_mask & 2,1,0)) - SUM(IF(r.bit_mask & 1,1,0))');
     $args['query'] = M('Purchase')->report()->getReportQueryUserList();
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     return $args;
 }
Exemplo n.º 21
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['aliases'] = array('id' => 'an.id', 'user_id' => 'an.user_id', 'writer_id' => 'an.writer_id', 'body' => 'an.body', 'posted' => 'an.posted', 'type' => 'an.type', 'type_no_action' => 'u.type_no_action', 'city_id' => 'u.city_id');
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
         $args['no_visible'][] = 'city_id';
     }
     $args['query'] = M('AdminNote')->getReportQuery();
     return $args;
 }
Exemplo n.º 22
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['aliases'] = qw2('user_id>r.user_id bdate>r.bdate receipt_virt>receipt_virt receipt_real>receipt_real receipt_diff>receipt_diff total_discount_diff>total_discount_diff city_id>u.city_id');
     $args['having'] = array('receipt_virt' => 'SUM(IF(r.bit_mask & 2,1,0))', 'receipt_real' => 'SUM(IF(r.bit_mask & 1,1,0))', 'receipt_diff' => 'SUM(IF(r.bit_mask & 2,1,0)) - SUM(IF(r.bit_mask & 1,1,0))', 'total_discount_diff' => 'RIUND( SUM(IF(r.bit_mask & 1,r.total_virt*(1-r.discount_virt),0)) - SUM(IF(r.bit_mask & 1,r.total_real*(1-r.discount_real),0)), 2)');
     $args['query'] = M('Purchase')->report()->getReportQueryReceiptStatistic();
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     return $args;
 }
Exemplo n.º 23
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['aliases'] = qw2('bdate>bdate user_id>r.user_id number>number total_real>total_real discount_real>discount_real total_discount>total_discount shop_id>shop_id inn_tail>inn_tail checker_id>checker_id cdate_real>cdate_real diff>diff city_id>u.city_id');
     $args['having'] = array('total_discount' => 'ROUND(total_real*(1 - discount_real),2)', 'diff' => 'ROUND( IFNULL(total_virt,0)*(1 - IFNULL(discount_virt,0)) - IFNULL(total_real,0)*(1 - IFNULL(discount_real,0)) ,2)');
     $args['query'] = M('Purchase')->report()->getReportQueryRealReceipts();
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     return $args;
 }
Exemplo n.º 24
0
 /**
  * Creates and returns report object (not save!) 
  *
  * @param		string|NULL		type
  * @return		RM_Report_Object
  **/
 public function createReport($type = NULL)
 {
     if (!me()->id()) {
         throw new Exception(__METHOD__ . '(): cannot create report for anonymous user!');
     }
     $data = array('report_type' => $type, 'parent_id' => 0, 'hash_id' => md5(M('Tools')->misc()->randomKeys(32) . microtime(true)), 'owner_id' => me()->id());
     $obReport = $this->_mapper->storage('report')->createObject($data);
     $obReport->setDefaultPermissions();
     return $obReport;
 }
Exemplo n.º 25
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['aliases'] = array('user_id' => 'u.user_id', 'date_from' => 'l.date_from', 'date_to' => 'l.date_to', 'cdate' => 'l.cdate', 'city_id' => 'u.city_id');
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     $args['filter']['date_to >= DATE(?)'] = M('Tools')->date()->dbdate();
     $args['query'] = M('User')->report()->getLeaveReportQuery();
     return $args;
 }
Exemplo n.º 26
0
 public function delete()
 {
     if (($this->city_id != me()->city_id || !$this->city_id) && !me()->isUserInGroup('federal-news')) {
         $this->_permissionDenied();
     }
     if ($this->city_id == me()->city_id && !me()->isUserInGroup('regional-news')) {
         $this->_permissionDenied();
     }
     parent::delete();
 }
Exemplo n.º 27
0
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (me()->isUserInGroup(array('points-unlimit'))) {
         return TRUE;
     }
     if (abs($data[$field]) <= C('point.group-limit')) {
         return TRUE;
     }
     $result->error('limit', $field);
     return FALSE;
 }
Exemplo n.º 28
0
 /**
  * Enter description here...
  *
  * @return void
  */
 public function _init($data = array())
 {
     foreach ($this->_obInvoice->getItemsList()->filter('invoice_state = ?', RM_Holder_Invoice_Item_State::ADD) as $obItem) {
         $obEntity = $obItem->getEntity();
         $obEntity->setHolder();
         $obEntity->setInvoice($this->_obInvoice);
         $obEntity->save();
     }
     $this->_obInvoice->out_date = M('Date')->dbDateTime();
     $this->_obInvoice->sender_id = me()->id();
 }
Exemplo n.º 29
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['aliases'] = array('id' => 'p.id', 'date_entered' => 'r.bdate', 'user_id' => 'p.user_id', 'corrected_name' => 'p.corrected_name', 'status_id' => 'p.status_id', 'barcode_value' => 'p.barcode_value', 'check_id' => 'r.number', 'price' => 'p.price', 'discount' => 'p.discount', 'unit_id' => 'p.unit_id', 'quantity' => 'p.quantity', 'shop_id' => 'r.shop_id', 'is_deleted' => 'p.is_deleted', 'city_id' => 'u.city_id', 'date_saved' => 'p.date_saved');
     if (!$this->canChangeBarcode(me())) {
         $args['no_visible'][] = 'barcode_to_change';
     }
     if ($this->restrictByCity()) {
         $args['filter']['city_id = ?'] = me()->city_id;
     }
     $args['query'] = M('Purchase')->report()->getPurchaseReportQuery();
     $args['query']->what('0 as barcode_to_change');
     return $args;
 }
Exemplo n.º 30
0
 /**
  *	Returns additional params (query object, column etc.) for report
  *
  *	@param		array		args
  *	@return		array
  **/
 public function getAdditionalParams($args)
 {
     $args['query'] = M('Barcode')->report()->barcodeListQuery(TRUE);
     if (!MC('User')->canDeleteBarcode(me())) {
         $args['no_visible'][] = 'delete';
     }
     if (!MC('User')->canSetIsFood(me())) {
         $args['no_visible'][] = 'is_food';
     }
     if (!MC('User')->canSendBarcodeToRefresh(me())) {
         $args['no_visible'][] = 'to_refresh';
     }
     return $args;
 }