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


PHP UserList::insert方法代码示例

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


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

示例1: insertListItem

 function insertListItem($listName, $itemName)
 {
     $model = new UserList();
     $model->system_list_code = $listName;
     $model->system_list_item_name = $itemName;
     $model->system_list_item_code = $listName . '_' . $itemName;
     $model->system_list_item_active = '1';
     $condition = 'system_list_item_code=:id';
     if (!$model->getItemByCode($listName . '_' . $itemName)) {
         $model->insert();
     }
 }
开发者ID:heartshare,项目名称:linxbooks,代码行数:12,代码来源:UserList.php

示例2: createList

 /**
  * Create a User list for the user.
  *
  * Parameters:
  * <ul>
  * <li>username - The barcode of the user.  Can be truncated to the last 7 or 9 digits.</li>
  * <li>password - The pin number for the user. </li>
  * <li>title    - The title of the list to create.</li>
  * <li>description - A description for the list (optional).</li>
  * <li>public   - Set to true or 1 if the list should be public.  (optional, defaults to private).</li>
  * </ul>
  *
  * Note: You may also provide the parameters to addTitlesToList and titles will be added to the list
  * after the list is created.
  *
  * Returns:
  * <ul>
  * <li>success - true if the account is valid and the list could be created, false if the username or password were incorrect or the list could not be created.</li>
  * <li>listId - te id of the new list that is created.</li>
  * </ul>
  *
  * Sample Call:
  * <code>
  * http://catalog.douglascountylibraries.org/API/ListAPI?method=createList&username=23025003575917&password=1234&title=Test+List&description=Test&public=0
  * </code>
  *
  * Sample Response:
  * <code>
  * {"result":{"success":true,"listId":"1688"}}
  * </code>
  */
 function createList()
 {
     $username = $_REQUEST['username'];
     $password = $_REQUEST['password'];
     if (!isset($_REQUEST['title'])) {
         return array('success' => false, 'message' => 'You must provide the title of the list to be created.');
     }
     global $user;
     $user = UserAccount::validateAccount($username, $password);
     if ($user && !PEAR_Singleton::isError($user)) {
         $list = new UserList();
         $list->title = $_REQUEST['title'];
         $list->description = isset($_REQUEST['description']) ? $_REQUEST['description'] : '';
         $list->public = isset($_REQUEST['public']) ? $_REQUEST['public'] == true || $_REQUEST['public'] == 1 ? 1 : 0 : 0;
         $list->user_id = $user->id;
         $list->insert();
         $list->find();
         if (!isset($_REQUEST['recordIds'])) {
             $result = $this->addTitlesToList();
             return $result;
         }
         return array('success' => true, 'listId' => $list->id);
     } else {
         return array('success' => false, 'message' => 'Login unsuccessful');
     }
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:57,代码来源:ListAPI.php

示例3: addList

 function addList()
 {
     if ($this->user) {
         if (strlen(trim($_REQUEST['title'])) == 0) {
             return new PEAR_Error('list_edit_name_required');
         }
         $list = new UserList();
         $list->title = $_REQUEST['title'];
         $list->description = $_REQUEST['desc'];
         $list->public = $_REQUEST['public'];
         $list->user_id = $this->user->id;
         $list->insert();
         $list->find();
         return $list->id;
     } else {
         return false;
     }
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:18,代码来源:ListEdit.php

示例4: importListsFromIls

 /**
  * Import Lists from the ILS
  *
  * @return array - an array of results including the names of the lists that were imported as well as number of titles.
  */
 function importListsFromIls()
 {
     require_once ROOT_DIR . '/sys/LocalEnrichment/UserList.php';
     global $user;
     $results = array('totalTitles' => 0, 'totalLists' => 0);
     $patronDump = $this->_getPatronDump($this->_getBarcode());
     //Get the page which contains a table with all lists in them.
     $listsPage = $this->_fetchPatronInfoPage($patronDump, 'mylists');
     //Get the actual table
     if (preg_match('/<table[^>]*?class="patFunc"[^>]*?>(.*?)<\\/table>/si', $listsPage, $listsPageMatches)) {
         $allListTable = $listsPageMatches[1];
         //Now that we have the table, get the actual list names and ids
         preg_match_all('/<tr[^>]*?class="patFuncEntry"[^>]*?>.*?<input type="checkbox" id ="(\\d+)".*?<a.*?>(.*?)<\\/a>.*?<td[^>]*class="patFuncDetails">(.*?)<\\/td>.*?<\\/tr>/si', $allListTable, $listDetails, PREG_SET_ORDER);
         for ($listIndex = 0; $listIndex < count($listDetails); $listIndex++) {
             $listId = $listDetails[$listIndex][1];
             $title = $listDetails[$listIndex][2];
             $description = str_replace('&nbsp;', '', $listDetails[$listIndex][3]);
             //Create the list (or find one that already exists)
             $newList = new UserList();
             $newList->user_id = $user->id;
             $newList->title = $title;
             if (!$newList->find(true)) {
                 $newList->description = $description;
                 $newList->insert();
             }
             $currentListTitles = $newList->getListTitles();
             //Get a list of all titles within the list to be imported
             $listDetailsPage = $this->_fetchPatronInfoPage($patronDump, 'mylists?listNum=' . $listId);
             //Get the table for the details
             if (preg_match('/<table[^>]*?class="patFunc"[^>]*?>(.*?)<\\/table>/si', $listDetailsPage, $listsDetailsMatches)) {
                 $listTitlesTable = $listsDetailsMatches[1];
                 //Get the bib numbers for the title
                 preg_match_all('/<input type="checkbox" name="(b\\d{1,7})".*?<span[^>]*class="patFuncTitle(?:Main)?">(.*?)<\\/span>/si', $listTitlesTable, $bibNumberMatches, PREG_SET_ORDER);
                 for ($bibCtr = 0; $bibCtr < count($bibNumberMatches); $bibCtr++) {
                     $bibNumber = $bibNumberMatches[$bibCtr][1];
                     $bibTitle = strip_tags($bibNumberMatches[$bibCtr][2]);
                     //Get the grouped work for the resource
                     require_once ROOT_DIR . '/sys/Grouping/GroupedWorkPrimaryIdentifier.php';
                     require_once ROOT_DIR . '/sys/Grouping/GroupedWork.php';
                     $primaryIdentifier = new GroupedWorkPrimaryIdentifier();
                     $groupedWork = new GroupedWork();
                     $primaryIdentifier->identifier = '.' . $bibNumber . $this->getCheckDigit($bibNumber);
                     $primaryIdentifier->type = 'ils';
                     $primaryIdentifier->joinAdd($groupedWork);
                     if ($primaryIdentifier->find(true)) {
                         //Check to see if this title is already on the list.
                         $resourceOnList = false;
                         foreach ($currentListTitles as $currentTitle) {
                             if ($currentTitle->groupedWorkPermanentId == $primaryIdentifier->permanent_id) {
                                 $resourceOnList = true;
                                 break;
                             }
                         }
                         if (!$resourceOnList) {
                             $listEntry = new UserListEntry();
                             $listEntry->groupedWorkPermanentId = $primaryIdentifier->permanent_id;
                             $listEntry->listId = $newList->id;
                             $listEntry->notes = '';
                             $listEntry->dateAdded = time();
                             $listEntry->insert();
                         }
                     } else {
                         //The title is not in the resources, add an error to the results
                         if (!isset($results['errors'])) {
                             $results['errors'] = array();
                         }
                         $results['errors'][] = "\"{$bibTitle}\" on list {$title} could not be found in the catalog and was not imported.";
                     }
                     $results['totalTitles']++;
                 }
             }
             $results['totalLists'] += 1;
         }
     }
     return $results;
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:81,代码来源:Millennium.php

示例5: actionAjaxLoadFormItem

 function actionAjaxLoadFormItem()
 {
     $model = new UserList();
     $list_code = $_POST['list'];
     if (isset($_POST['item']) && $_POST['item'] !== "") {
         $item = $_POST['item'];
         $model->system_list_code = $list_code;
         $model->system_list_item_name = $item;
         $model->system_list_item_code = $list_code . '_' . $item;
         $model->system_list_item_active = '1';
         $condition = 'system_list_item_code=:id';
         if (!$model->getItemByCode($list_code . '_' . $item)) {
             $model->insert();
             echo json_encode(array('status' => 'success'));
         } else {
             echo json_encode(array('status' => 'failed'));
         }
     }
 }
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:19,代码来源:ConfigurationController.php

示例6: saveToList

 function saveToList()
 {
     $result = array();
     global $user;
     if ($user === false) {
         $result['result'] = false;
         $result['message'] = 'Please login before adding a title to list.';
     } else {
         require_once ROOT_DIR . '/sys/LocalEnrichment/UserList.php';
         require_once ROOT_DIR . '/sys/LocalEnrichment/UserListEntry.php';
         $result['result'] = true;
         $id = $_REQUEST['id'];
         $listId = $_REQUEST['listId'];
         $notes = $_REQUEST['notes'];
         //Check to see if we need to create a list
         $userList = new UserList();
         $listOk = true;
         if (empty($listId)) {
             $userList->title = "My Favorites";
             $userList->user_id = $user->id;
             $userList->public = 0;
             $userList->description = '';
             $userList->insert();
         } else {
             $userList->id = $listId;
             if (!$userList->find(true)) {
                 $result['result'] = false;
                 $result['message'] = 'Sorry, we could not find that list in the system.';
                 $listOk = false;
             }
         }
         if ($listOk) {
             $userListEntry = new UserListEntry();
             $userListEntry->listId = $userList->id;
             $userListEntry->groupedWorkPermanentId = $id;
             $existingEntry = false;
             if ($userListEntry->find(true)) {
                 $existingEntry = true;
             }
             $userListEntry->notes = $notes;
             $userListEntry->dateAdded = time();
             if ($existingEntry) {
                 $userListEntry->update();
             } else {
                 $userListEntry->insert();
             }
         }
         $result['result'] = true;
         $result['message'] = 'This title was saved to your list successfully.';
     }
     return json_encode($result);
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:52,代码来源:AJAX.php

示例7: AddList

 function AddList()
 {
     global $user;
     $return = array();
     if ($user) {
         require_once ROOT_DIR . '/sys/LocalEnrichment/UserList.php';
         $title = isset($_REQUEST['title']) ? urldecode($_REQUEST['title']) : '';
         if (strlen(trim($title)) == 0) {
             $return['result'] = "false";
             $return['message'] = "You must provide a title for the list";
         } else {
             $list = new UserList();
             $list->title = $title;
             $list->user_id = $user->id;
             //Check to see if there is already a list with this id
             $existingList = false;
             if ($list->find(true)) {
                 $existingList = true;
             }
             $list->description = urldecode($_REQUEST['desc']);
             $list->public = $_REQUEST['public'];
             if ($existingList) {
                 $list->update();
             } else {
                 $list->insert();
             }
             if (isset($_REQUEST['recordId'])) {
                 $recordToAdd = urldecode($_REQUEST['recordId']);
                 require_once ROOT_DIR . '/sys/LocalEnrichment/UserListEntry.php';
                 //Check to see if the user has already added the title to the list.
                 $userListEntry = new UserListEntry();
                 $userListEntry->listId = $list->id;
                 $userListEntry->groupedWorkPermanentId = $recordToAdd;
                 if (!$userListEntry->find(true)) {
                     $userListEntry->dateAdded = time();
                     $userListEntry->insert();
                 }
             }
             $return['result'] = 'true';
             $return['newId'] = $list->id;
             if ($existingList) {
                 $return['message'] = "Updated list {$title} successfully";
             } else {
                 $return['message'] = "Created list {$title} successfully";
             }
         }
     } else {
         $return['result'] = "false";
         $return['message'] = "You must be logged in to create a list";
     }
     return $return;
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:52,代码来源:AJAX.php


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