当前位置: 首页>>代码示例>>PHP>>正文


PHP ca_users::getPrimaryKey方法代码示例

本文整理汇总了PHP中ca_users::getPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_users::getPrimaryKey方法的具体用法?PHP ca_users::getPrimaryKey怎么用?PHP ca_users::getPrimaryKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca_users的用法示例。


在下文中一共展示了ca_users::getPrimaryKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticate

 public static function authenticate($ps_username, $ps_password = '', $pa_options = null)
 {
     $t_user = new ca_users();
     $t_user->load($ps_username);
     if ($t_user->getPrimaryKey() > 0) {
         $vs_hash = $t_user->get('password');
         if (preg_match('/^[a-f0-9]{32}$/', $vs_hash)) {
             // old-style md5 passwords
             //throw new CaUsersException(_t('The stored password for this user seems to be in legacy format. Please update the user account by resetting the password.'));
             if (md5($ps_password) == $vs_hash) {
                 // if the md5 hash matches, authenticate successfully and move the user over to pbkdf2 key
                 $t_user->setMode(ACCESS_WRITE);
                 // ca_users::update takes care of the hashing by calling AuthenticationManager::updatePassword()
                 $t_user->set('password', $ps_password);
                 $t_user->update();
                 return true;
             } else {
                 return false;
             }
         }
         return validate_password($ps_password, $vs_hash);
     } else {
         return false;
     }
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:25,代码来源:CaUsers.php

示例2: createUser

 /**
  * Creates a new active user
  * 
  * @param string $user_name user name
  * @param string $password password
  * @param string $email email address
  * @param string $fname first name
  * @param string $lname  last name
  * @return int identifier of the new user
  * @throws SoapFault
  */
 public function createUser($user_name, $password, $email, $fname, $lname)
 {
     $t_user = new ca_users();
     $t_user->set("user_name", $user_name);
     $t_user->set("password", $password);
     $t_user->set("email", $email);
     $t_user->set("fname", $fname);
     $t_user->set("lname", $lname);
     $t_user->set("active", 1);
     $t_user->setMode(ACCESS_WRITE);
     $t_user->insert();
     if ($t_user->numErrors()) {
         throw new SoapFault("Server", "Could not create user: " . join(" ", $t_user->getErrors()));
     }
     return $t_user->getPrimaryKey();
 }
开发者ID:samrahman,项目名称:providence,代码行数:27,代码来源:AccessControlService.php

示例3: testBooleanOperators

 public function testBooleanOperators()
 {
     $vo_acr = AccessRestrictions::load(true);
     // OR
     $va_access_restrictions = array("administrate/setup/list_editor/ListEditorController" => array("default" => array("operator" => "OR", "actions" => array("can_edit_ca_lists", "can_create_ca_lists", "can_delete_ca_lists"))));
     $vo_acr->opa_acr = $va_access_restrictions;
     // no role -> can't access controller
     $this->opt_role->setMode(ACCESS_WRITE);
     $this->opt_role->setRoleActions(array());
     $this->opt_role->update();
     ca_users::$s_user_action_access_cache = array();
     $vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
     $this->assertFalse($vb_access);
     // has one of the OR-ed roles -> can access controller
     $this->opt_role->setMode(ACCESS_WRITE);
     $va_actions = $va_access_restrictions["administrate/setup/list_editor/ListEditorController"]["default"]["actions"];
     $this->opt_role->setRoleActions(array($va_actions[array_rand($va_actions)]));
     $this->opt_role->update();
     ca_users::$s_user_action_access_cache = array();
     $vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
     $this->assertTrue($vb_access);
     // AND
     $va_access_restrictions = array("administrate/setup/list_editor/ListEditorController" => array("default" => array("operator" => "AND", "actions" => array("can_edit_ca_lists", "can_create_ca_lists", "can_delete_ca_lists"))));
     $vo_acr->opa_acr = $va_access_restrictions;
     // no role -> can't access controller
     $this->opt_role->setMode(ACCESS_WRITE);
     $this->opt_role->setRoleActions(array());
     $this->opt_role->update();
     ca_users::$s_user_action_access_cache = array();
     $vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
     $this->assertFalse($vb_access);
     // has one of the AND-ed roles -> can't access controller
     $this->opt_role->setMode(ACCESS_WRITE);
     $va_actions = $va_access_restrictions["administrate/setup/list_editor/ListEditorController"]["default"]["actions"];
     $this->opt_role->setRoleActions(array($va_actions[array_rand($va_actions)]));
     $this->opt_role->update();
     ca_users::$s_user_action_access_cache = array();
     $vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
     $this->assertFalse($vb_access);
     // has all AND-ed roles -> can access controller
     $this->opt_role->setMode(ACCESS_WRITE);
     $this->opt_role->setRoleActions($va_actions);
     $this->opt_role->update();
     ca_users::$s_user_action_access_cache = array();
     $vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
     $this->assertTrue($vb_access);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:47,代码来源:AccessControlTest.php

示例4: send

 /**
  * 
  */
 public static function send($pn_user_id, $ps_message)
 {
     global $AUTH_CURRENT_USER_ID, $g_request;
     if (!function_exists("curl_init")) {
         return false;
     }
     if ($pn_user_id == $AUTH_CURRENT_USER_ID) {
         $t_user = $g_request->user;
         // use request user object
     } else {
         $t_user = new ca_users($pn_user_id);
     }
     if (!$t_user->getPrimaryKey()) {
         return null;
     }
     if (!$t_user->get('sms_number')) {
         return null;
     }
     if (!($vn_sendhub_contact_id = $t_user->getVar('sms_sendhub_contact_id')) || $t_user->getVar('sms_sendhub_phone_number') != $t_user->get('sms_number')) {
         if (!($vn_sendhub_contact_id = WLPlugSMSSendHub::addContact($t_user))) {
             // TODO: check and log errors here
             return null;
         }
     }
     $vs_user = $t_user->getAppConfig()->get('sms_user');
     $vs_api_key = $t_user->getAppConfig()->get('sms_api_key');
     $vs_url = "https://api.sendhub.com/v1/messages/?username={$vs_user}&api_key={$vs_api_key}";
     $o_ch = curl_init();
     $ps_message = stripslashes(rawurldecode($ps_message));
     $ps_message = trim(preg_replace("!\n+!", "\\" . "n", $ps_message));
     curl_setopt($o_ch, CURLOPT_URL, $vs_url);
     curl_setopt($o_ch, CURLOPT_HEADER, false);
     curl_setopt($o_ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
     curl_setopt($o_ch, CURLOPT_POSTFIELDS, '{"contacts":[' . $vn_sendhub_contact_id . '],"text":"' . $ps_message . '"}');
     curl_setopt($o_ch, CURLOPT_RETURNTRANSFER, 1);
     $vs_return = curl_exec($o_ch);
     $va_return = json_decode($vs_return);
     // TODO: check and log errors here
     curl_close($o_ch);
     return true;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:44,代码来源:SendHub.php

示例5: resetSave

 function resetSave()
 {
     MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . _t("Reset Password"));
     $ps_action = $this->request->getParameter('action', pString);
     if (!$ps_action) {
         $ps_action = "reset";
     }
     $ps_key = $this->request->getParameter('key', pString);
     $ps_key = preg_replace("/[^A-Za-z0-9]+/", "", $ps_key);
     $this->view->setVar("key", $ps_key);
     $this->view->setVar("email", $this->request->config->get("ca_admin_email"));
     $o_check_key = new Db();
     $qr_check_key = $o_check_key->query("\n\t\t\t\tSELECT user_id \n\t\t\t\tFROM ca_users \n\t\t\t\tWHERE\n\t\t\t\t\tmd5(concat(concat(user_id, '/'), password)) = ?\n\t\t\t", $ps_key);
     #
     # Check reset key
     #
     if (!$qr_check_key->nextRow() || !($vs_user_id = $qr_check_key->get("user_id"))) {
         $this->view->setVar("action", "reset_failure");
         $this->view->setVar("message", _t("Your password could not be reset"));
         $this->render('LoginReg/form_reset_html.php');
     } else {
         $ps_password = $this->request->getParameter('password', pString);
         $ps_password_confirm = $this->request->getParameter('password_confirm', pString);
         switch ($ps_action) {
             case 'reset_save':
                 if (!$ps_password || !$ps_password_confirm) {
                     $this->view->setVar("message", _t("Please enter and re-type your password."));
                     $ps_action = "reset";
                     break;
                 }
                 if ($ps_password != $ps_password_confirm) {
                     $this->view->setVar("message", _t("Passwords do not match. Please try again."));
                     $ps_action = "reset";
                     break;
                 }
                 $t_user = new ca_users();
                 $t_user->purify(true);
                 $t_user->load($vs_user_id);
                 # verify user exists with this e-mail address
                 if ($t_user->getPrimaryKey()) {
                     # user with e-mail already exists...
                     $t_user->setMode(ACCESS_WRITE);
                     $t_user->set("password", $ps_password);
                     $t_user->update();
                     if ($t_user->numErrors()) {
                         $this->notification->addNotification(join("; ", $t_user->getErrors()), __NOTIFICATION_TYPE_INFO__);
                         $ps_action = "reset_failure";
                     } else {
                         $ps_action = "reset_success";
                         $o_view = new View($this->request, array($this->request->getViewsDirectoryPath()));
                         # -- generate email subject
                         $vs_subject_line = $o_view->render("mailTemplates/notification_subject.tpl");
                         # -- generate mail text from template - get both the html and text versions
                         $vs_mail_message_text = $o_view->render("mailTemplates/notification.tpl");
                         $vs_mail_message_html = $o_view->render("mailTemplates/notification_html.tpl");
                         caSendmail($t_user->get('email'), $this->request->config->get("ca_admin_email"), $vs_subject_line, $vs_mail_message_text, $vs_mail_message_html);
                     }
                     break;
                 } else {
                     $this->notification->addNotification(_t("Invalid user"), __NOTIFICATION_TYPE_INFO__);
                     $ps_action = "reset_failure";
                 }
         }
         $this->view->setVar("action", $ps_action);
         $this->render('LoginReg/form_reset_html.php');
     }
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:67,代码来源:LoginRegController.php

示例6: getSetsForUser

 public function getSetsForUser($pa_options)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $pn_user_id = isset($pa_options['user_id']) ? (int) $pa_options['user_id'] : null;
     $pm_table_name_or_num = isset($pa_options['table']) ? $pa_options['table'] : null;
     if ($pm_table_name_or_num && !($vn_table_num = $this->_getTableNum($pm_table_name_or_num))) {
         return null;
     }
     $pm_type = isset($pa_options['setType']) ? $pa_options['setType'] : null;
     $pn_access = isset($pa_options['access']) ? $pa_options['access'] : null;
     $pa_public_access = isset($pa_options['checkAccess']) ? $pa_options['checkAccess'] : null;
     if ($pa_public_access && is_numeric($pa_public_access) && !is_array($pa_public_access)) {
         $pa_public_access = array($pa_public_access);
     }
     for ($vn_i = 0; $vn_i < sizeof($pa_public_access); $vn_i++) {
         $pa_public_access[$vn_i] = intval($pa_public_access[$vn_i]);
     }
     if ($pn_user_id) {
         $va_extra_joins = array();
         $va_sql_wheres = array("(cs.deleted = 0)");
         $va_sql_params = array();
         $o_db = $this->getDb();
         if ($vn_table_num) {
             $va_sql_wheres[] = "(cs.table_num = ?)";
             $va_sql_params[] = (int) $vn_table_num;
         }
         if (!is_null($pa_public_access) && is_array($pa_public_access) && sizeof($pa_public_access)) {
             $va_sql_wheres[] = "(cs.access IN (?))";
             $va_sql_params[] = $pa_public_access;
         }
         if (isset($pm_type) && $pm_type) {
             if (is_numeric($pm_type)) {
                 $va_sql_wheres[] = "(cs.type_id = ?)";
                 $va_sql_params[] = (int) $pm_type;
             } else {
                 # --- look up code of set type
                 $t_list = new ca_lists();
                 $vn_type_id = $t_list->getItemIDFromList("set_types", $pm_type);
                 if ($vn_type_id) {
                     $va_sql_wheres[] = "(cs.type_id = ?)";
                     $va_sql_params[] = (int) $vn_type_id;
                 }
             }
         }
         if ($pa_options["owner"]) {
             $va_sql_wheres[] = "(cs.user_id = " . $pn_user_id . ")";
         } else {
             # --- if owner is not set to true, we're finding all sets the user has access to or is owner of
             # --- we also check the users' access to the set if set
             $t_user = new ca_users();
             $t_user->load($pn_user_id);
             if ($t_user->getPrimaryKey()) {
                 $vs_access_sql = $pn_access > 0 ? " AND (access >= " . intval($pn_access) . ")" : "";
                 if (is_array($va_groups = $t_user->getUserGroups()) && sizeof($va_groups)) {
                     $vs_sql = "(\n\t\t\t\t\t\t\t(cs.user_id = " . intval($pn_user_id) . ") OR \n\t\t\t\t\t\t\t(cs.set_id IN (\n\t\t\t\t\t\t\t\t\tSELECT set_id \n\t\t\t\t\t\t\t\t\tFROM ca_sets_x_user_groups \n\t\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t\tgroup_id IN (" . join(',', array_keys($va_groups)) . ") {$vs_access_sql}\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t (sdatetime IS NULL AND edatetime IS NULL)\n\t\t\t\t\t\t\t\t\t\t\t OR \n\t\t\t\t\t\t\t\t\t\t\t (\n\t\t\t\t\t\t\t\t\t\t\t\tsdatetime <= " . time() . " AND edatetime >= " . time() . "\n\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)";
                 } else {
                     $vs_sql = "(cs.user_id = {$pn_user_id})";
                 }
                 $vs_sql .= " OR (cs.set_id IN (\n\t\t\t\t\t\t\t\t\t\t\tSELECT set_id \n\t\t\t\t\t\t\t\t\t\t\tFROM ca_sets_x_users \n\t\t\t\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t\t\t\tuser_id = {$pn_user_id} {$vs_access_sql}\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t (sdatetime IS NULL AND edatetime IS NULL)\n\t\t\t\t\t\t\t\t\t\t\t\t\t OR \n\t\t\t\t\t\t\t\t\t\t\t\t\t (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsdatetime <= " . time() . " AND edatetime >= " . time() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)";
                 $va_sql_wheres[] = "({$vs_sql})";
             }
         }
         $qr_res = $o_db->query("SELECT cs.set_id, cs.user_id, type_id, cu.fname, cu.lname\n\t\t\t\t\t\t\t\t\tFROM ca_sets cs\n\t\t\t\t\t\t\t\t\tINNER JOIN ca_users AS cu ON cs.user_id = cu.user_id\n\t\t\t\t\t\t\t\t\t" . join("\n", $va_extra_joins) . "\n\t\t\t\t\t\t\t\t\t" . (sizeof($va_sql_wheres) ? "WHERE " : "") . " " . join(" AND ", $va_sql_wheres) . "\n\t\t\t\t\t\t\t\t\t", $va_sql_params);
         $va_sets = array();
         $t_list = new ca_lists();
         while ($qr_res->nextRow()) {
             $vn_table_num = $qr_res->get('table_num');
             if (!isset($va_type_name_cache[$vn_table_num]) || !($vs_set_type = $va_type_name_cache[$vn_table_num])) {
                 $vs_set_type = $va_type_name_cache[$vn_table_num] = $this->getSetContentTypeName($vn_table_num, array('number' => 'plural'));
             }
             $vs_type = $t_list->getItemFromListForDisplayByItemID('set_types', $qr_res->get('type_id'));
             $va_sets[$qr_res->get('set_id')] = array_merge($qr_res->getRow(), array('set_content_type' => $vs_set_type, 'set_type' => $vs_type));
         }
         return $va_sets;
     } else {
         return false;
     }
 }
开发者ID:kai-iak,项目名称:providence,代码行数:80,代码来源:ca_sets.php

示例7: search

 public function search($pn_subject_tablenum, $ps_search_expression, $pa_filters = array(), $po_rewritten_query = null)
 {
     $vn_i = 0;
     $va_old_signs = $po_rewritten_query->getSigns();
     $va_terms = $va_signs = array();
     foreach ($po_rewritten_query->getSubqueries() as $o_lucene_query_element) {
         switch ($vs_class = get_class($o_lucene_query_element)) {
             case 'Zend_Search_Lucene_Search_Query_Term':
             case 'Zend_Search_Lucene_Search_Query_MultiTerm':
             case 'Zend_Search_Lucene_Search_Query_Phrase':
                 $vs_access_point = null;
                 if ($vs_class != 'Zend_Search_Lucene_Search_Query_Term') {
                     $va_raw_terms = array();
                     foreach ($o_lucene_query_element->getQueryTerms() as $o_term) {
                         if (!$vs_access_point && ($vs_field = $o_term->field)) {
                             $vs_access_point = $vs_field;
                         }
                         $va_raw_terms[] = $vs_text = (string) $o_term->text;
                     }
                     $vs_term = join(" ", $va_raw_terms);
                 } else {
                     $vs_access_point = $o_lucene_query_element->getTerm()->field;
                     $vs_term = $o_lucene_query_element->getTerm()->text;
                     $o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('"' . $vs_term . '"', $vs_access_point));
                 }
                 if ($vs_access_point) {
                     list($vs_table, $vs_field, $vs_sub_field) = explode('.', $vs_access_point);
                     if (in_array($vs_table, array('created', 'modified'))) {
                         if (!$this->opo_tep->parse($vs_term)) {
                             break;
                         }
                         $vn_user_id = null;
                         if ($vs_field = trim($vs_field)) {
                             if (!is_int($vs_field)) {
                                 $t_user = new ca_users();
                                 if ($t_user->load(array("user_name" => $vs_field))) {
                                     $vn_user_id = (int) $t_user->getPrimaryKey();
                                 }
                             } else {
                                 $vn_user_id = (int) $vs_field;
                             }
                         }
                         switch ($vs_table) {
                             case 'created':
                                 if ($vn_user_id) {
                                     $o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Boolean(array(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', 'created'), new Zend_Search_Lucene_Index_Term($vn_user_id, 'created_user_id')), array(true, true));
                                 } else {
                                     $o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', 'created'));
                                 }
                                 break;
                             case 'modified':
                                 if ($vn_user_id) {
                                     $o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Boolean(array(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', 'modified'), new Zend_Search_Lucene_Index_Term($vn_user_id, 'modified_user_id')), array(true, true));
                                 } else {
                                     $o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', 'modified'));
                                 }
                                 break;
                         }
                     } else {
                         if ($vs_table && $vs_field) {
                             $t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true);
                             if (!$t_table) {
                                 break;
                             }
                             $vs_fld_num = $this->opo_datamodel->getFieldNum($vs_table, $vs_field);
                             if (!$vs_fld_num) {
                                 // probably attribute
                                 $t_element = new ca_metadata_elements();
                                 if ($t_element->load(array('element_code' => $vs_sub_field ? $vs_sub_field : $vs_field))) {
                                     //
                                     // For certain types of attributes we can directly query the
                                     // attributes in the database rather than using the full text index
                                     // This allows us to do "intelligent" querying... for example on date ranges
                                     // parsed from natural language input and for length dimensions using unit conversion
                                     //
                                     switch ($t_element->get('datatype')) {
                                         case 2:
                                             // dates
                                             $vb_exact = $vs_term[0] == "#" ? true : false;
                                             // dates prepended by "#" are considered "exact" or "contained - the matched dates must be wholly contained by the search term
                                             if ($vb_exact) {
                                                 if ($this->opo_tep->parse($vs_term)) {
                                                     // TODO: fix date handling to reflect distinctions in ranges
                                                     $o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', $vs_access_point));
                                                 }
                                             } else {
                                                 if ($this->opo_tep->parse($vs_term)) {
                                                     // TODO: fix date handling to reflect distinctions in ranges
                                                     $o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', $vs_access_point));
                                                 }
                                             }
                                             break;
                                         case 4:
                                             // geocode
                                             $t_geocode = new GeocodeAttributeValue();
                                             if ($va_coords = caParseGISSearch($vs_term)) {
                                                 $o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $va_coords['min_latitude'] . ',' . $va_coords['min_longitude'] . " TO " . $va_coords['max_latitude'] . ',' . $va_coords['max_longitude'] . ']', $vs_access_point));
                                             }
                                             break;
                                         case 6:
//.........这里部分代码省略.........
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:101,代码来源:ElasticSearch.php

示例8: _doQueriesForSqlSearch


//.........这里部分代码省略.........
                                             }
                                             $va_ft_stem_terms[] = "'" . $this->opo_db->escape($vs_stem) . "'";
                                         } else {
                                             $va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
                                         }
                                     } else {
                                         $va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
                                     }
                                 }
                                 $vb_output_term = true;
                             }
                             if ($vb_output_term) {
                                 $va_raw_terms[] = $vs_term;
                             }
                         }
                         break;
                 }
                 $vs_fld_num = $vs_table_num = $t_table = null;
                 $vb_ft_bit_optimization = false;
                 if ($vs_access_point) {
                     list($vs_table, $vs_field, $vs_sub_field) = explode('.', $vs_access_point);
                     if (in_array($vs_table, array('created', 'modified'))) {
                         $o_tep = new TimeExpressionParser();
                         $vs_date = join(' ', $va_raw_terms);
                         if (!$o_tep->parse($vs_date)) {
                             break;
                         }
                         $va_range = $o_tep->getUnixTimestamps();
                         $vn_user_id = null;
                         if ($vs_field = trim($vs_field)) {
                             if (!is_int($vs_field)) {
                                 $t_user = new ca_users();
                                 if ($t_user->load(array("user_name" => $vs_field))) {
                                     $vn_user_id = (int) $t_user->getPrimaryKey();
                                 }
                             } else {
                                 $vn_user_id = (int) $vs_field;
                             }
                         }
                         $vs_user_sql = $vn_user_id ? " AND (ccl.user_id = " . (int) $vn_user_id . ")" : "";
                         switch ($vs_table) {
                             case 'created':
                                 $vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.logged_table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.changetype = 'I')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
                                 break;
                             case 'modified':
                                 $vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.logged_table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.changetype = 'U')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccls.subject_row_id row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_change_log_subjects AS ccls ON ccls.log_id = ccl.log_id\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccls.subject_table_num = {$pn_subject_tablenum})\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
                                 break;
                         }
                     } else {
                         if ($vs_table && $vs_field && ($t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true))) {
                             $vs_table_num = $t_table->tableNum();
                             if (is_numeric($vs_field)) {
                                 $vs_fld_num = 'I' . $vs_field;
                                 $vn_fld_num = (int) $vs_field;
                             } else {
                                 $vn_fld_num = $this->getFieldNum($vs_table, $vs_field);
                                 $vs_fld_num = 'I' . $vn_fld_num;
                                 $vn_direct_sql_target_table_num = $vs_table_num;
                                 if (!strlen($vn_fld_num)) {
                                     $t_element = new ca_metadata_elements();
                                     if ($t_element->load(array('element_code' => $vs_sub_field ? $vs_sub_field : $vs_field))) {
                                         $va_indexed_fields = $o_base->getFieldsToIndex($pn_subject_tablenum, $vn_direct_sql_target_table_num);
                                         $vn_fld_num = $t_element->getPrimaryKey();
                                         $vn_root_element_id = $t_element->get('hier_element_id');
                                         if (!isset($va_indexed_fields['_ca_attribute_' . $vn_fld_num]) && (!$vn_root_element_id || $vn_root_element_id && !isset($va_indexed_fields['_ca_attribute_' . $vn_root_element_id]))) {
                                             break 2;
开发者ID:ymani2435,项目名称:providence,代码行数:67,代码来源:SqlSearch.php

示例9: addTask

 /**
  * Options for addTask()
  *
  *	"user_id" 		= user_id to associate task with; leave blank for "nobody" (aka. system)
  *	"priority"		= priority to give task; lower numbers get processed first; default is 10
  *	"entity_key"	= unique identifier for entity task operates on [optional]. Will be stored as md5 hash
  *	"row_key"		= unique identifier for row task operates on. Will be stored as md5 hash
  *	"notes"			= descriptive text for queued task
  *
  */
 function addTask($ps_handler, $pa_parameters, $pa_options)
 {
     #
     # Check user_id
     #
     $vn_user_id = "";
     if (isset($pa_options["user_id"])) {
         $t_user = new ca_users($pa_options["user_id"]);
         $vn_user_id = $t_user->getPrimaryKey();
     }
     $vn_user_id = $vn_user_id ? intval($vn_user_id) : null;
     #
     # Check priority
     #
     $vn_priority = intval($pa_options["priority"]);
     if ($vn_priority < 1 || $vn_priority > 1000) {
         $vn_priority = 10;
     }
     #
     # Convert parameters to array if it is not one already
     #
     if (!is_array($pa_parameters)) {
         $pa_parameters = array($pa_parameters);
     }
     $o_db = new Db();
     $o_db->query("\n\t\t\tINSERT INTO ca_task_queue\n\t\t\t(user_id, entity_key, row_key, created_on, started_on, completed_on, priority, handler, parameters, notes)\n\t\t\tVALUES\n\t\t\t(?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?)\n\t\t", $vn_user_id, md5($pa_options["entity_key"]), md5($pa_options["row_key"]), time(), $vn_priority, $ps_handler, base64_encode(serialize($pa_parameters)), $pa_options["notes"] ? $pa_options["notes"] : '');
     if ($o_db->numErrors()) {
         $this->postError(503, join('; ', $o_db->getErrors()), "TaskQueue->addTask()");
         return false;
     }
     return $o_db->getLastInsertID();
 }
开发者ID:ffarago,项目名称:pawtucket2,代码行数:42,代码来源:TaskQueue.php

示例10: checkout

 /**
  * Checkout an object for a user. Will throw an exception if the item is currently out or object or user_id are invalid;
  *
  * @param int $pn_object_id
  * @param int $pn_user_id
  * @param string $ps_note Optional checkin notes
  * @param string $ps_due_date A valid date time expression for the date item is due to be returned. If omitted the default date as configured will be used.
  * @param array $pa_options
  *
  * @return bool True on success, false on failure
  */
 public function checkout($pn_object_id, $pn_user_id, $ps_note = null, $ps_due_date = null, $pa_options = null)
 {
     global $g_ui_locale_id;
     $vb_we_set_transaction = false;
     if ($this->inTransaction()) {
         $o_trans = $this->getTransaction();
     } else {
         $vb_we_set_transaction = true;
         $this->setTransaction($o_trans = new Transaction());
     }
     $o_request = caGetOption('request', $pa_options, null);
     $t_object = new ca_objects($pn_object_id);
     $t_object->setTransaction($o_trans);
     if (!$t_object->getPrimaryKey()) {
         throw new Exception(_t('Object_id is not valid'));
     }
     if ($o_request && !$t_object->isReadable($o_request)) {
         throw new Exception(_t('Object_id is not accessible'));
     }
     $t_user = new ca_users($pn_user_id);
     if (!$t_user->getPrimaryKey()) {
         throw new Exception(_t('User_id is not valid'));
     }
     // is object available?
     if (!in_array($t_object->getCheckoutStatus(), array(__CA_OBJECTS_CHECKOUT_STATUS_AVAILABLE__, __CA_OBJECTS_CHECKOUT_STATUS_RESERVED__))) {
         throw new Exception(_t('Item is already out'));
     }
     // is there a reservation for this user?
     $o_db = $o_trans->getDb();
     $qr_res = $o_db->query("\n\t\t\tSELECT *\n\t\t\tFROM ca_object_checkouts\n\t\t\tWHERE\n\t\t\t\tuser_id = ? AND object_id = ? AND checkout_date IS NULL AND return_date IS NULL\n\t\t\tORDER BY \n\t\t\t\tcreated_on\n\t\t", array($pn_user_id, $pn_object_id));
     $vb_update = false;
     if ($qr_res->nextRow()) {
         $vs_uuid = $qr_res->get('group_uuid');
         if ($this->load($qr_res->get('checkout_id'))) {
             $vb_update = true;
         }
     } else {
         $vs_uuid = $this->getTransactionUUID();
     }
     $va_checkout_config = ca_object_checkouts::getObjectCheckoutConfigForType($t_object->getTypeCode());
     if (!($va_checkout_config['allow_override_of_due_dates'] && $ps_due_date && caDateToUnixTimestamp($ps_due_date))) {
         // calculate default return date
         $ps_due_date = isset($va_checkout_config['default_checkout_date']) ? $va_checkout_config['default_checkout_date'] : null;
     }
     $this->setMode(ACCESS_WRITE);
     $this->set(array('group_uuid' => $vs_uuid, 'object_id' => $pn_object_id, 'user_id' => $pn_user_id, 'checkout_notes' => $ps_note, 'checkout_date' => _t('today'), 'due_date' => $ps_due_date));
     // Do we need to set values?
     if (is_array($va_checkout_config['set_values']) && sizeof($va_checkout_config['set_values'])) {
         $t_object->setMode(ACCESS_WRITE);
         foreach ($va_checkout_config['set_values'] as $vs_attr => $va_attr_values_by_event) {
             if (!is_array($va_attr_values_by_event['checkout'])) {
                 if ($t_object->hasField($vs_attr)) {
                     // Intrinsic
                     $t_object->set($vs_attr, $va_attr_values_by_event['checkout']);
                 }
             } else {
                 $va_attr_values['locale_id'] = $g_ui_locale_id;
                 $t_object->replaceAttribute($va_attr_values_by_event['checkout'], $vs_attr);
             }
             $t_object->update();
             if ($t_object->numErrors()) {
                 $this->errors = $t_object->errors;
                 if ($vb_we_set_transaction) {
                     $o_trans->rollback();
                 }
                 return false;
             }
         }
     }
     $vn_rc = $vb_update ? $this->update() : $this->insert();
     if ($vb_we_set_transaction) {
         $vn_rc ? $o_trans->commit() : $o_trans->rollback();
     }
     return $vn_rc;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:86,代码来源:ca_object_checkouts.php

示例11: getCriterionLabel

 /**
  * Returns a display label for a given criterion and facet.
  *
  * @param string $ps_facet_name Name of facet 
  * @param mixed $pm_criterion 
  * @return string
  */
 public function getCriterionLabel($ps_facet_name, $pn_row_id)
 {
     if (!($va_facet_info = $this->getInfoForFacet($ps_facet_name))) {
         return null;
     }
     switch ($va_facet_info['type']) {
         # -----------------------------------------------------
         case 'has':
             $vs_yes_text = isset($va_facet_info['label_yes']) && $va_facet_info['label_yes'] ? $va_facet_info['label_yes'] : _t('Yes');
             $vs_no_text = isset($va_facet_info['label_no']) && $va_facet_info['label_no'] ? $va_facet_info['label_no'] : _t('No');
             return (bool) $pn_row_id ? $vs_yes_text : $vs_no_text;
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'label':
             if (!($t_table = $this->opo_datamodel->getInstanceByTableName(isset($va_facet_info['relative_to']) && $va_facet_info['relative_to'] ? $va_facet_info['relative_to'] : $this->ops_browse_table_name, true))) {
                 break;
             }
             if (!$t_table->load($pn_row_id)) {
                 return '???';
             }
             return $t_table->getLabelForDisplay();
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'authority':
             if (!($t_table = $this->opo_datamodel->getInstanceByTableName($va_facet_info['table'], true))) {
                 break;
             }
             if (!$t_table->load($pn_row_id)) {
                 return '???';
             }
             return $t_table->getLabelForDisplay();
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'attribute':
             $t_element = new ca_metadata_elements();
             if (!$t_element->load(array('element_code' => $va_facet_info['element_code']))) {
                 return urldecode($pn_row_id);
             }
             $vn_element_id = $t_element->getPrimaryKey();
             switch ($vn_element_type = $t_element->get('datatype')) {
                 case __CA_ATTRIBUTE_VALUE_LIST__:
                     $t_list = new ca_lists();
                     return $t_list->getItemFromListForDisplayByItemID($t_element->get('list_id'), $pn_row_id, true);
                     break;
                 case __CA_ATTRIBUTE_VALUE_OBJECTS__:
                 case __CA_ATTRIBUTE_VALUE_ENTITIES__:
                 case __CA_ATTRIBUTE_VALUE_PLACES__:
                 case __CA_ATTRIBUTE_VALUE_OCCURRENCES__:
                 case __CA_ATTRIBUTE_VALUE_COLLECTIONS__:
                 case __CA_ATTRIBUTE_VALUE_LOANS__:
                 case __CA_ATTRIBUTE_VALUE_MOVEMENTS__:
                 case __CA_ATTRIBUTE_VALUE_STORAGELOCATIONS__:
                 case __CA_ATTRIBUTE_VALUE_OBJECTLOTS__:
                     if ($t_rel_item = AuthorityAttributeValue::elementTypeToInstance($vn_element_type)) {
                         return $t_rel_item->load($pn_row_id) ? $t_rel_item->getLabelForDisplay() : "???";
                     }
                     break;
                 default:
                     return urldecode($pn_row_id);
                     break;
             }
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'field':
             if (!($t_item = $this->opo_datamodel->getInstanceByTableName($this->ops_browse_table_name, true))) {
                 break;
             }
             if ($vb_is_bit = $t_item->getFieldInfo($va_facet_info['field'], 'FIELD_TYPE') == FT_BIT) {
                 return (bool) $pn_row_id ? caGetOption('label_yes', $va_facet_info, _t('Yes')) : caGetOption('label_no', $va_facet_info, _t('No'));
             }
             return urldecode($pn_row_id);
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'violations':
             if (!($t_rule = $this->opo_datamodel->getInstanceByTableName('ca_metadata_dictionary_rules', true))) {
                 break;
             }
             if ($t_rule->load(array('rule_code' => $pn_row_id))) {
                 return $t_rule->getSetting('label');
             }
             return urldecode($pn_row_id);
             break;
             # -----------------------------------------------------
         # -----------------------------------------------------
         case 'checkouts':
             $vs_status_text = null;
             $vs_status_code = isset($va_facet_info['status']) && $va_facet_info['status'] ? $va_facet_info['status'] : $pn_row_id;
             switch ($vs_status_code) {
//.........这里部分代码省略.........
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:101,代码来源:BrowseEngine.php

示例12: _doQueriesForSqlSearch


//.........这里部分代码省略.........
                                         $va_ft_stem_terms[] = "'" . $this->opo_db->escape($vs_stem) . "'";
                                     } else {
                                         $va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
                                     }
                                 } else {
                                     $va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
                                 }
                                 $vb_output_term = true;
                             }
                         }
                         if ($vb_output_term) {
                             $va_raw_terms[] = $vs_term;
                         } else {
                             $vn_i--;
                         }
                         break;
                 }
                 $vs_fld_num = $vs_table_num = $t_table = null;
                 $vb_ft_bit_optimization = false;
                 if ($vs_access_point) {
                     list($vs_table, $vs_field, $vs_sub_field) = explode('.', $vs_access_point);
                     if (in_array($vs_table, array('created', 'modified'))) {
                         $o_tep = new TimeExpressionParser();
                         $vs_date = join(' ', $va_raw_terms);
                         if (!$o_tep->parse($vs_date)) {
                             break;
                         }
                         $va_range = $o_tep->getUnixTimestamps();
                         $vn_user_id = null;
                         if ($vs_field = trim($vs_field)) {
                             if (!is_int($vs_field)) {
                                 $t_user = new ca_users();
                                 if ($t_user->load(array("user_name" => $vs_field))) {
                                     $vn_user_id = (int) $t_user->getPrimaryKey();
                                 }
                             } else {
                                 $vn_user_id = (int) $vs_field;
                             }
                         }
                         $vs_user_sql = $vn_user_id ? " AND (ccl.user_id = " . (int) $vn_user_id . ")" : "";
                         switch ($vs_table) {
                             case 'created':
                                 $vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.logged_table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.changetype = 'I')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
                                 break;
                             case 'modified':
                                 $vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.logged_table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.changetype = 'U')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccls.subject_row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_change_log_subjects AS ccls ON ccls.log_id = ccl.log_id\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccls.subject_table_num = {$pn_subject_tablenum})\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
                                 break;
                         }
                     } else {
                         if ($vs_table && $vs_field) {
                             $t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true);
                             if ($t_table) {
                                 $vs_table_num = $t_table->tableNum();
                                 if (is_numeric($vs_field)) {
                                     $vs_fld_num = 'I' . $vs_field;
                                     $vn_fld_num = (int) $vs_field;
                                 } else {
                                     $vn_fld_num = $this->getFieldNum($vs_table, $vs_field);
                                     $vs_fld_num = 'I' . $vn_fld_num;
                                     if (!strlen($vn_fld_num)) {
                                         $t_element = new ca_metadata_elements();
                                         if ($t_element->load(array('element_code' => $vs_sub_field ? $vs_sub_field : $vs_field))) {
                                             $vn_fld_num = $t_element->getPrimaryKey();
                                             $vs_fld_num = 'A' . $vn_fld_num;
                                             if (!$vb_is_blank_search) {
                                                 //
开发者ID:guaykuru,项目名称:pawtucket,代码行数:67,代码来源:SqlSearch.php

示例13: removeUsers

 /**
  * Remove current user from one or more groups.
  *
  * @access public
  * @param mixed $pm_groups Single group or list (array) of user_ids to remove from current group. Users must be specified by user_id
  * @return bool Returns true on success, false on error.
  */
 function removeUsers($pm_user_ids)
 {
     if (!is_array($pm_user_ids)) {
         $pm_user_ids = array($pm_user_ids);
     }
     if ($pn_group_id = $this->getPrimaryKey()) {
         $t_user = new ca_users();
         $vn_users_added = 0;
         $va_user_ids = array();
         foreach ($pm_user_ids as $pn_user_id) {
             if (!$t_user->load((int) $pn_user_id)) {
                 continue;
             }
             $va_user_ids[] = intval($t_user->getPrimaryKey());
         }
         if (sizeof($va_user_ids) > 0) {
             $o_db = $this->getDb();
             $o_db->query("\n\t\t\t\t\tDELETE FROM ca_users_x_groups \n\t\t\t\t\tWHERE (group_id = ?) AND (user_id IN (" . join(", ", $va_user_ids) . "))\n\t\t\t\t", (int) $pn_group_id);
             if ($o_db->numErrors()) {
                 $this->postError(936, _t("Database error: %1", join(';', $o_db->getErrors())), "ca_user_groups->removeUsers()");
                 return false;
             } else {
                 return true;
             }
         } else {
             $this->postError(945, _t("No users specified"), "ca_user_groups->removeUsers()");
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:39,代码来源:ca_user_groups.php

示例14: hookPeriodicTask

 /**
  * Perform periodic tasks
  *
  * @return boolean true because otherwise it disables subsequent plugins
  */
 public function hookPeriodicTask(&$pa_params)
 {
     global $AUTH_CURRENT_USER_ID;
     $t_log = new Eventlog();
     $o_db = new Db();
     //$t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Could not authenticate to remote system %1', $vs_base_url), 'SOURCE' => 'traveloguePlugin->hookPeriodicTask'));
     // Get new email
     $pn_locale_id = 1;
     // US
     $vs_server = $this->opo_config->get('imap_server');
     $vs_username = $this->opo_config->get('username');
     $vs_password = $this->opo_config->get('password');
     $vs_ssl = $this->opo_config->get('ssl');
     if (!$vs_server) {
         return true;
     }
     if (!$vs_username) {
         return true;
     }
     try {
         $o_mail = new Zend_Mail_Storage_Imap(array('host' => $vs_server, 'user' => $vs_username, 'password' => $vs_password, 'ssl' => $vs_ssl));
     } catch (Exception $e) {
         return true;
     }
     $va_mimetypes = $this->opo_config->getList('mimetypes');
     $va_mail_to_delete = array();
     foreach ($o_mail as $vn_message_num => $o_message) {
         $va_mail_to_delete[$vn_message_num] = true;
         // Extract title from subject line of email
         $vs_subject = $o_message->subject;
         $vs_from = $o_message->headerExists('from') ? $o_message->from : "";
         print "PROCESSING {$vs_subject} FROM {$vs_from}\n";
         // Extract media from email attachments
         // Extract caption from email body
         $va_images = array();
         $va_texts = array();
         foreach (new RecursiveIteratorIterator($o_message) as $o_part) {
             try {
                 if (in_array(strtok($o_part->contentType, ';'), $va_mimetypes)) {
                     $va_images[] = $o_part;
                 } else {
                     if (in_array(strtok($o_part->contentType, ';'), array("text/plain", "text/html"))) {
                         $va_texts[] = (string) $o_part;
                     }
                 }
             } catch (Zend_Mail_Exception $e) {
                 // ignore
             }
         }
         if (!sizeof($va_images)) {
             continue;
         }
         // Get user by email address
         if (preg_match('!<([^>]+)>!', $vs_from, $va_matches)) {
             // extract raw address from "from" header
             $vs_from = $va_matches[1];
         }
         $t_user = new ca_users();
         if ($t_user->load(array('email' => $vs_from))) {
             $AUTH_CURRENT_USER_ID = $vn_user_id = $t_user->getPrimaryKey();
             // force libs to consider matched user as logged in; change log will reflect this name
         } else {
             $vn_user_id = null;
         }
         // Create object
         $t_object = new ca_objects();
         $t_object->setMode(ACCESS_WRITE);
         $t_object->set('type_id', $this->opo_config->get('object_type'));
         // TODO: set idno to autogenerated # and/or allow for configurable policy
         $t_object->set('idno', '');
         $t_object->set('access', $this->opo_config->get('default_access'));
         $t_object->set('status', $this->opo_config->get('default_status'));
         // TODO: make this a configurable mapping ala how media metadata is done
         $t_object->addAttribute(array('locale_id' => $pn_locale_id, 'generalNotes' => join("\n\n", $va_texts)), 'generalNotes');
         $t_object->insert();
         DataMigrationUtils::postError($t_object, "While adding object", "traveloguePlugin");
         // TODO: log this
         $t_object->addLabel(array('name' => $vs_subject), $pn_locale_id, null, true);
         DataMigrationUtils::postError($t_object, "While adding label", "traveloguePlugin");
         // TODO: log this
         // Add representation
         $vs_tmp_file_path = tempnam(caGetTempDirPath(), 'travelogue_');
         foreach ($va_images as $vn_i => $vs_file_content) {
             if (file_put_contents($vs_tmp_file_path, base64_decode((string) $vs_file_content))) {
                 $t_object->addRepresentation($vs_tmp_file_path, $this->opo_config->get('representation_type'), 1, $this->opo_config->get('default_status'), $this->opo_config->get('default_access'), true);
                 DataMigrationUtils::postError($t_object, "While adding media", "traveloguePlugin");
                 // TODO: log this
             }
         }
         // TODO: add option to link user-as-entity to image (probably as creator)
     }
     foreach (array_reverse(array_keys($va_mail_to_delete)) as $vn_message_num) {
         $o_mail->removeMessage($vn_message_num);
     }
     return true;
//.........这里部分代码省略.........
开发者ID:samrahman,项目名称:providence,代码行数:101,代码来源:traveloguePlugin.php

示例15: getFulfillmentLog

 /**
  * Returns a list of fulfillment events for the currently loaded order
  *
  * @param array $pa_options An array of options (none supported yet)
  * @return array A list of arrays, each containing information about a specific fulfillment event. The list is ordered by date/time starting with the oldest event.
  */
 public function getFulfillmentLog($pa_options = null)
 {
     if (!($vn_order_id = $this->getPrimaryKey())) {
         return null;
     }
     $o_db = $this->getDb();
     $qr_res = $o_db->query("\n\t\t\tSELECT e.*, i.*, o.idno item_idno\n\t\t\tFROM ca_commerce_fulfillment_events e \n\t\t\tINNER JOIN ca_commerce_order_items AS i ON i.item_id = e.item_id\n\t\t\tINNER JOIN ca_objects AS o ON o.object_id = i.object_id\n\t\t\tWHERE \n\t\t\t\te.order_id = ?\n\t\t\tORDER BY e.occurred_on\n\t\t", (int) $vn_order_id);
     $t_object = new ca_objects();
     $va_labels = $t_object->getPreferredDisplayLabelsForIDs($qr_res->getAllFieldValues("object_id"));
     $t_item = new ca_commerce_order_items();
     $va_events = array();
     $qr_res->seek(0);
     $va_user_cache = array();
     while ($qr_res->nextRow()) {
         $va_row = $qr_res->getRow();
         $va_row['fulfillment_details'] = caUnserializeForDatabase($va_row['fulfillment_details']);
         $va_row['item_label'] = $va_labels[$va_row['object_id']];
         $va_row['fulfillment_method_display'] = $t_item->getChoiceListValue('fullfillment_method', $va_row['fullfillment_method']);
         $va_row['service_display'] = $t_item->getChoiceListValue('service', $va_row['service']);
         if ($vn_user_id = (int) $va_row['fulfillment_details']['user_id']) {
             if (!isset($va_user_cache[$vn_user_id])) {
                 $t_user = new ca_users($vn_user_id);
                 if ($t_user->getPrimaryKey()) {
                     $va_user_cache[$vn_user_id] = array('fname' => $t_user->get('fname'), 'lname' => $t_user->get('lname'), 'email' => $t_user->get('email'));
                 } else {
                     $va_user_cache[$vn_user_id] = null;
                 }
             }
             if (is_array($va_user_cache[$vn_user_id])) {
                 $va_row = array_merge($va_row, $va_user_cache[$vn_user_id]);
             }
         }
         $va_events[] = $va_row;
     }
     return $va_events;
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:42,代码来源:ca_commerce_orders.php


注:本文中的ca_users::getPrimaryKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。