Ejemplo n.º 1
0
 public function setForUpdate(Am_Record $record, array $vars)
 {
     if (isset($vars['pass'])) {
         $record->setPass($vars['pass']);
         unset($vars['pass']);
     }
     parent::setForUpdate($record, $vars);
 }
Ejemplo n.º 2
0
 public function delete()
 {
     $ret = parent::delete();
     $table_name = $this->getTable()->getName();
     $this->getAdapter()->query("UPDATE {$table_name}\n            SET sort_order=sort_order-1\n            WHERE sort_order>?", $this->sort_order);
     return $ret;
 }
Ejemplo n.º 3
0
 function delete()
 {
     $this->getAdapter()->query('UPDATE ?_email_template
         SET email_template_layout_id = NULL
         WHERE email_template_layout_id=?', $this->pk());
     return parent::delete();
 }
Ejemplo n.º 4
0
 public function delete()
 {
     foreach ($this->loadGetAttachments() as $att) {
         /* @var $att Upload */
         if ($att->prefix == Bootstrap_Helpdesk::ATTACHMENT_UPLOAD_PREFIX) {
             $att->delete();
         }
     }
     parent::delete();
 }
Ejemplo n.º 5
0
 public function fromRow(array $arr)
 {
     // fields to decrypt
     foreach ($this->_encryptedFields as $f) {
         if (array_key_exists($f, $arr)) {
             $arr[$f] = $this->_table->decrypt($arr[$f]);
         }
     }
     return parent::fromRow($arr);
 }
Ejemplo n.º 6
0
 public function insert($reload = true)
 {
     if ($this->currency == Am_Currency::getDefault()) {
         $this->base_currency_multi = 1.0;
     } else {
         $this->base_currency_multi = $this->getDi()->currencyExchangeTable->getRate($this->currency, sqlDate($this->dattm));
     }
     parent::insert($reload);
     $this->getDi()->hook->call(new Am_Event_PaymentAfterInsert(null, array('payment' => $this, 'invoice' => $this->getInvoice(), 'user' => $this->getInvoice()->getUser())));
     return $this;
 }
Ejemplo n.º 7
0
 public function insert($reload = true)
 {
     if ($this->currency == Am_Currency::getDefault()) {
         $this->base_currency_multi = 1.0;
     } else {
         $this->base_currency_multi = $this->getDi()->currencyExchangeTable->getRate($this->currency, sqlDate($this->dattm));
     }
     $ret = parent::insert($reload);
     $this->getDi()->hook->call('refundAfterInsert', array('invoice' => $this->getInvoice(), 'refund' => $this, 'user' => $this->getInvoice()->getUser()));
     return $ret;
 }
Ejemplo n.º 8
0
 public function fromRow(array $vars)
 {
     if (isset($vars['childNodes'])) {
         foreach ($vars['childNodes'] as $row) {
             $r = new self($this->getTable());
             $r->fromRow($row);
             $this->_childNodes[] = $r;
         }
         unset($vars['childNodes']);
     }
     return parent::fromRow($vars);
 }
Ejemplo n.º 9
0
 public function update()
 {
     $hm = $this->getDi()->hook;
     if ($hm->have(Am_Event::ACCESS_AFTER_UPDATE)) {
         $old = $this->getTable()->load($this->pk());
     }
     parent::update();
     $this->runHooks();
     if ($hm->have(Am_Event::ACCESS_AFTER_UPDATE)) {
         $this->getDi()->hook->call(Am_Event::ACCESS_AFTER_UPDATE, array('access' => $this, 'old' => $old));
     }
     return $this;
 }
Ejemplo n.º 10
0
 /**
  * before record insertion generate new ticket mask. if the mask is generated, try
  * 20 times to generate new mask, then throw exception
  * @return type 
  */
 public function insert($reload = true)
 {
     $maxAttempts = 20;
     for ($i = 0; $i <= $maxAttempts; $i++) {
         try {
             $this->_generateMask();
             return parent::insert($reload);
         } catch (Am_Exception_Db_NotUnique $e) {
             if ($i >= $maxAttempts) {
                 throw new Am_Exception_InternalError("Could not generate new ticket mask after [{$i}] attempts");
             }
             $this->ticket_mask = null;
         }
     }
 }
Ejemplo n.º 11
0
 public function delete()
 {
     parent::delete();
     $this->getDi()->hook->call(Am_Event::ADMIN_AFTER_DELETE, array('admin' => $this));
 }
Ejemplo n.º 12
0
 function log(Am_Record $user, Am_Record $notification)
 {
     $this->_db->query("INSERT INTO ?_notification_click SET ?a", array('user_id' => $user->pk(), 'dattm' => sqlDate('now'), 'notification_id' => $notification->pk()));
 }
Ejemplo n.º 13
0
 function __construct(Am_Record $record)
 {
     foreach (get_class_vars(get_class($this)) as $k => $v) {
         if ($k == '_params') {
             continue;
         }
         $this->{$k} = $record->get($k);
     }
     $this->setParams(new JRegistry());
     $this->aid = $this->gid == 18 ? 1 : 2;
     $this->guest = 0;
 }
Ejemplo n.º 14
0
 function getWpCorsewareGroups(Am_Record $record)
 {
     return $this->_db->selectCol('SELECT course_id FROM ?_wpcw_user_courses WHERE user_id=?', $record->pk());
 }
Ejemplo n.º 15
0
 function getGroups(Am_Record $record)
 {
     switch ($this->_groupMode) {
         case Am_Protect_Databased::GROUP_NONE:
             return null;
         case Am_Protect_Databased::GROUP_MULTI:
             if ($this->_groupTableConfig) {
                 $table = $this->_groupTableConfig[Am_Protect_Table::GROUP_TABLE];
                 $uidField = $this->_groupTableConfig[Am_Protect_Table::GROUP_UID];
                 $gidField = $this->_groupTableConfig[Am_Protect_Table::GROUP_GID];
                 return $this->_db->selectCol("SELECT {$gidField} FROM {$table} WHERE {$uidField}=?", $record->pk());
             }
             break;
         case Am_Protect_Databased::GROUP_SINGLE:
             /// may be a field set
             $field = null;
             foreach ($this->_fieldsMapping as $a) {
                 list($k, $v) = $a;
                 if ($k == Am_Protect_Table::FIELD_GROUP_ID) {
                     $field = $v;
                     break;
                 }
             }
             if ($field) {
                 $v = $record->get($field);
                 return $v;
             }
             break;
     }
     throw new Am_Exception_NotImplemented(get_class($this) . "->getGroups() is not implemented");
 }
Ejemplo n.º 16
0
 function delete()
 {
     $this->deleteFromRelatedTable('?_coupon');
     parent::delete();
 }
Ejemplo n.º 17
0
 public function _valuesToForm(array &$values, Am_Record $record)
 {
     if ($record->isLoaded()) {
         $values['_category'] = $record->getCategories();
     }
     parent::_valuesToForm($values, $record);
 }
Ejemplo n.º 18
0
 function delete()
 {
     $fullPath = $this->getFullPath();
     if (file_exists($fullPath)) {
         if (!unlink($fullPath)) {
             throw new Am_Exception_InternalError("Could not delete [{$fullPath}], and corresponding database records also is not deleted");
         }
     }
     parent::delete();
 }
Ejemplo n.º 19
0
 protected function addEncryptedPass(Am_Record $user, $lineParsed, $format)
 {
     $user_id = $user->pk();
     if ($format == SavedPassTable::PASSWORD_PHPASS) {
         /* Special Case for Native aMember Hash Format */
         $field = $this->getImportField('pass', self::FIELD_TYPE_ENCRYPTED_PASS);
         $user->updateQuick('pass', $field->getValue($lineParsed));
     } else {
         $savedPass = $this->getDi()->savedPassTable->findFirstBy(array('user_id' => $user_id, 'format' => $format));
         if (!$savedPass) {
             $savedPass = $this->getDi()->savedPassRecord;
             $savedPass->format = $format;
             $savedPass->user_id = $user_id;
         }
         foreach ($this->getImportFields(self::FIELD_TYPE_ENCRYPTED_PASS) as $field) {
             $field->setValueForRecord($savedPass, $lineParsed);
         }
         $savedPass->save();
     }
     $user->data()->set(Am_Protect_Databased::USER_NEED_SETPASS, 1);
     $user->save();
 }
Ejemplo n.º 20
0
 function setGroups(Am_Record $record, $groups)
 {
     $old_groups = $this->_plugin->getWP()->get_user_meta($record->pk(), $this->_plugin->getConfig('prefix') . "capabilities");
     $ret = array();
     foreach ($groups as $k) {
         if ($k) {
             $ret[$k] = 1;
         }
     }
     $this->_plugin->getWP()->update_user_meta($record->pk(), $this->_plugin->getConfig('prefix') . "capabilities", $ret);
     $this->updateLevel($record, $this->getLevelFromCaps($record));
     return $ret;
 }
Ejemplo n.º 21
0
 /**
  * insert records from $this->_nestedInput 
  * after $record->insert() call 
  */
 public function insertNested(Am_Record $record, array $vars)
 {
     foreach ($this->_nestedInput as $nest => $records) {
         $controller = $this->getNestedController($nest);
         foreach ($records as $rec) {
             $rec[$this->getNestedKeyField($nest)] = $record->pk();
             $request = new Am_Request($rec, 'POST');
             $controller->setRequest($request);
             $controller->postAction();
         }
     }
 }
Ejemplo n.º 22
0
 public function delete()
 {
     parent::delete();
     $this->clearAccess();
 }
Ejemplo n.º 23
0
 function delete()
 {
     parent::delete();
     $this->deleteFromRelatedTable('?_aff_commission_commission_rule');
 }
Ejemplo n.º 24
0
 function update()
 {
     $this->status = get_first($this->status, self::STATUS_CHANGED);
     parent::update();
 }
Ejemplo n.º 25
0
 public function insert($reload = true)
 {
     if (!$this->_disablePostbackLog) {
         parent::insert($reload);
     }
     return $this;
 }
Ejemplo n.º 26
0
 function fromRow(array $vars)
 {
     $this->_isLoaded = true;
     return parent::fromRow($vars);
 }
Ejemplo n.º 27
0
 /**
  * Insert any collected fields before starting with child records
  */
 function startNestedTables()
 {
     if ($this->record) {
         $this->record->insert();
     }
 }
Ejemplo n.º 28
0
 public function __sleep()
 {
     $ret = parent::__sleep();
     $ret[] = '_dataStorage';
     return $ret;
 }
Ejemplo n.º 29
0
 public function insert($reload = true)
 {
     $ret = parent::insert(true);
     $max = $this->getAdapter()->selectCell("SELECT MAX(sort_order) FROM ?_resource_access_sort");
     $this->getAdapter()->query("\n            INSERT INTO ?_resource_access_sort\n            SET resource_id=?d, resource_type=?,\n                sort_order=?d\n        ", $this->pk(), $this->getAccessType(), 1 + $max);
     return $ret;
 }
Ejemplo n.º 30
0
 public function delete()
 {
     foreach ($this->getMessages() as $msg) {
         $msg->delete();
     }
     parent::delete();
 }