/**
  * Add $BULK_OPS to $UPDATE_DATA
  *
  * @param Rframe_Parser $parser
  * @param array         $path
  * @param array         $inits
  */
 public function __construct($parser, $path = array(), $inits = array())
 {
     foreach ($this->BULK_OPS as $key) {
         $this->UPDATE_DATA[] = $key;
     }
     parent::__construct($parser, $path, $inits);
 }
 /**
  * Don't allow the usual search/authz params
  *
  * @param Rframe_Parser $parser
  * @param array         $path
  * @param array         $inits
  */
 public function __construct($parser, $path = array(), $inits = array())
 {
     parent::__construct($parser, $path, $inits);
     air2_array_remove($this->search_param, $this->QUERY_ARGS);
     air2_array_remove($this->authz_read_param, $this->QUERY_ARGS);
     air2_array_remove($this->authz_write_param, $this->QUERY_ARGS);
     air2_array_remove($this->authz_manage_param, $this->QUERY_ARGS);
 }
 /**
  * Flatten
  *
  * @param InqOutcome $record
  */
 protected function format_radix(InqOutcome $record)
 {
     foreach ($this->fields as $fld) {
         if (is_string($fld) && preg_match('/^inq/', $fld)) {
             $record->mapValue($fld, $record->Inquiry->{$fld});
         }
     }
     return parent::format_radix($record);
 }
 /**
  * Flatten
  *
  * @param PrjOutcome $record
  */
 protected function format_radix(PrjOutcome $record)
 {
     // flatten project
     foreach ($this->fields as $fld) {
         if (is_string($fld) && preg_match('/^prj/', $fld)) {
             $record->mapValue($fld, $record->Project->{$fld});
         }
     }
     // project orgs
     $record->mapValue('ProjectOrg', $record->Project->ProjectOrg);
     return parent::format_radix($record);
 }
 /**
  * Flatten
  *
  * @param SrcOutcome $record
  */
 protected function format_radix(SrcOutcome $record)
 {
     foreach ($this->fields as $fld) {
         if (is_string($fld) && preg_match('/^src/', $fld)) {
             $record->mapValue($fld, $record->Source->{$fld});
         }
     }
     $record->mapValue('SrcEmail', $record->Source->SrcEmail);
     $record->mapValue('SrcPhoneNumber', $record->Source->SrcPhoneNumber);
     $record->mapValue('SrcMailAddress', $record->Source->SrcMailAddress);
     $record->mapValue('SrcOrg', $record->Source->SrcOrg);
     return parent::format_radix($record);
 }
 /**
  * Check for arrays
  *
  * @param string  $method
  * @param mixed   $return (reference)
  */
 protected function sanity($method, &$return)
 {
     if ($method == 'rec_query') {
         if (!(is_array($return) && !$this->is_assoc_array($return))) {
             throw new Exception("rec_query must return array");
         }
     } elseif ($method == 'rec_fetch') {
         if (!$this->is_assoc_array($return)) {
             throw new Exception("rec_fetch must return assoc-array");
         }
     } else {
         parent::sanity($method, $return);
     }
 }
 /**
  * Override parent method to sort responses with air2_sort_responses_for_display().
  *
  * @param Doctrine results $list
  * @return array
  */
 protected function format_query_radix($list)
 {
     $radix = parent::format_query_radix($list);
     $sorted_radix = air2_sort_responses_for_display($radix);
     return $sorted_radix;
 }
 /**
  * Also show 'unlocked' authz (for locked sources)
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid   (optional)
  * @param array   $extra (optional)
  * @return array $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     $resp = parent::format($mixed, $method, $uuid, $extra);
     // check for fetch-record
     if ($method == 'fetch' && is_a($mixed, 'Doctrine_Record') && isset($resp['authz'])) {
         $resp['authz']['unlock_write'] = $mixed->user_may_write($this->user, false);
         $resp['authz']['unlock_manage'] = $mixed->user_may_manage($this->user, false);
     }
     return $resp;
 }
 /**
  * Ensure question is not required.
  * Check for responses, and fix sequence AFTER deleting a question
  *
  * @param Question $rec
  */
 protected function rec_delete(Question $rec)
 {
     if ($rec->user_may_delete($this->user)) {
         if (in_array($rec->ques_template, array(Question::$TKEY_FIRSTNAME, Question::$TKEY_LASTNAME, Question::$TKEY_EMAIL, Question::$TKEY_ZIP))) {
             $msg = 'Unable to delete question: ' . $rec->ques_value . ' is required!';
             throw new Rframe_Exception(Rframe::BAD_DATA, $msg);
         }
         $conn = AIR2_DBManager::get_master_connection();
         $q = 'select count(*) from src_response where sr_ques_id = ?';
         $n = $conn->fetchOne($q, array($rec->ques_id), 0);
         if ($n > 0) {
             $msg = 'Unable to delete question: responses exist!';
             throw new Rframe_Exception(Rframe::BAD_DATA, $msg);
         }
     }
     parent::rec_delete($rec);
     $this->_fix_sequence();
 }
 /**
  * Override to allow returning raw strings
  *
  * @param string  $method
  * @param mixed   $return (reference)
  */
 protected function sanity($method, &$return)
 {
     if (!is_string($return)) {
         parent::sanity($method, $return);
     }
 }
 /**
  * Add extra data
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid   (optional)
  * @param array   $extra (optional)
  * @return array $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     $resp = parent::format($mixed, $method, $uuid, $extra);
     $resp['meta'] = array_merge($resp['meta'], $this->preview_extra);
     // include some header-validation data
     if (is_a($mixed, 'CSVImporter')) {
         $hdr_msg = $mixed->validate_headers();
         $hdr_valid = $hdr_msg === true ? true : false;
         if (!$hdr_valid) {
             $resp['message'] = $hdr_msg;
         }
         $this->parent_rec->set_meta_field('valid_header', $hdr_valid);
         $this->parent_rec->save();
     }
     return $resp;
 }
 /**
  * Add a title for the CSV file
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid  (optional)
  * @param array   $extra (optional)
  * @return array  $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     $resp = parent::format($mixed, $method, $uuid, $extra);
     $resp['filename'] = 'pinfluence_export.csv';
     return $resp;
 }
 /**
  * Allow READ-ing this resource without access to Source
  *
  * @throws Rframe_Exceptions
  * @param Doctrine_Record $rec
  * @param string $authz_type
  */
 protected function check_authz(Doctrine_Record $rec, $authz_type)
 {
     if ($authz_type != 'read') {
         parent::check_authz($rec, $authz_type);
     }
 }
Пример #14
0
 /**
  * Override to include user_may_send authz tests
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid   (optional)
  * @param array   $extra  (optional)
  * @return array $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     $resp = parent::format($mixed, $method, $uuid, $extra);
     if ($method == 'fetch' && is_a($mixed, 'Doctrine_Record')) {
         $resp['authz']['may_send'] = $mixed->user_may_send($this->user);
     }
     return $resp;
 }
Пример #15
0
 /**
  * Handle custom sorters
  *
  * @param Doctrine_Query $q
  * @param string $fld
  * @param string $dir
  */
 protected function rec_query_add_sort(Doctrine_Query $q, $fld, $dir)
 {
     if ($fld == 'cre_username') {
         $q->addOrderBy("cu.user_username {$dir}");
     } elseif ($fld == 'upd_username') {
         $q->addOrderBy("uu.user_username {$dir}");
     } else {
         parent::rec_query_add_sort($q, $fld, $dir);
     }
 }
 /**
  * Add "Conflict-With" data to fetch
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid   (optional)
  * @param array   $extra  (optional)
  * @return array $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     $data = parent::format($mixed, $method, $uuid, $extra);
     // only add on update/fetch, and only when status = CONFLICT
     if (!$data['success']) {
         return $data;
     }
     if ($method != 'update' && $method != 'fetch') {
         return $data;
     }
     if ($data['radix']['tsrc_status'] != TankSource::$STATUS_CONFLICT) {
         return $data;
     }
     // look for conflicts with something
     $withs = array();
     $cons = json_decode($data['radix']['tsrc_errors'], true);
     if ($cons) {
         if (isset($cons['initial'])) {
             foreach ($cons['initial'] as $key => $confl) {
                 if ($c = $this->_get_with($key, $confl)) {
                     $withs[$key] = $c;
                 }
             }
         }
         // make sure we didn't miss any
         if (isset($cons['last'])) {
             foreach ($cons['initial'] as $key => $confl) {
                 if (!isset($withs[$key]) && ($c = $this->_get_with($key, $confl))) {
                     $withs[$key] = $c;
                 }
             }
         }
     }
     $data['radix']['tsrc_withs'] = $withs;
     // also return the tsrc_id of the next conflict (if any)
     $conn = AIR2_DBManager::get_connection();
     $tid = $this->parent_rec->tank_id;
     $tsid = $data['radix']['tsrc_id'];
     $st = TankSource::$STATUS_CONFLICT;
     $q = "select tsrc_id from tank_source where tsrc_tank_id = ? " . "and tsrc_id != ? and tsrc_status = ? limit 1";
     $next = $conn->fetchOne($q, array($tid, $tsid, $st), 0);
     $data['radix']['next_conflict'] = $next;
     return $data;
 }
 /**
  * Mark inquiry as stale
  *
  * @param InquiryAuthor $rec
  */
 protected function update_parent(InquiryAuthor $rec)
 {
     $this->parent_rec->inq_stale_flag = 1;
     parent::update_parent($rec);
 }
Пример #18
0
 /**
  * Add 'bulk' operation data to $extra params
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid  (optional)
  * @param array   $extra (optional)
  * @return array  $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     if ($method == 'update' && $this->bulk_op) {
         $extra['bulk_op'] = $this->bulk_op;
         $extra['bulk_rs'] = $this->bulk_rs;
     }
     return parent::format($mixed, $method, $uuid, $extra);
 }