本文整理汇总了PHP中ca_sets::isInSet方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_sets::isInSet方法的具体用法?PHP ca_sets::isInSet怎么用?PHP ca_sets::isInSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_sets
的用法示例。
在下文中一共展示了ca_sets::isInSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AjaxAddItem
public function AjaxAddItem()
{
if (!$this->request->isLoggedIn()) {
$this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'loginForm'));
return;
}
global $g_ui_locale_id;
// current locale_id for user
$va_errors = array();
$o_purifier = new HTMLPurifier();
# --- set_id is passed through form, otherwise we're saving a new set, and adding the item to it
if ($this->request->getParameter('set_id', pInteger)) {
$t_set = $this->_getSet(__CA_EDIT_READ_ACCESS__);
if (!$t_set && ($t_set = $this->_getSet(__CA_SET_READ_ACCESS__))) {
$va_errors["general"] = _t("You can not add items to this lightbox. You have read only access.");
$this->view->setVar('errors', $va_errors);
$this->addItemForm();
return;
}
} else {
$t_set = new ca_sets();
# --- set name - if not sent, make a decent default
$ps_name = $o_purifier->purify($this->request->getParameter('name', pString));
if (!$ps_name) {
$ps_name = _t("Your lightbox");
}
# --- set description - optional
$ps_description = $o_purifier->purify($this->request->getParameter('description', pString));
$t_list = new ca_lists();
$vn_set_type_user = $t_list->getItemIDFromList('set_types', $this->request->config->get('user_set_type'));
$t_object = new ca_objects();
$vn_object_table_num = $t_object->tableNum();
$t_set->setMode(ACCESS_WRITE);
$t_set->set('access', 1);
#$t_set->set('access', $this->request->getParameter('access', pInteger));
$t_set->set('table_num', $vn_object_table_num);
$t_set->set('type_id', $vn_set_type_user);
$t_set->set('user_id', $this->request->getUserID());
$t_set->set('set_code', $this->request->getUserID() . '_' . time());
# --- create new attribute
if ($ps_description) {
$t_set->addAttribute(array('description' => $ps_description, 'locale_id' => $g_ui_locale_id), 'description');
}
$t_set->insert();
if ($t_set->numErrors()) {
$va_errors["general"] = join("; ", $t_set->getErrors());
$this->view->setVar('errors', $va_errors);
$this->addItemForm();
return;
} else {
# --- save name - add new label
$t_set->addLabel(array('name' => $ps_name), $g_ui_locale_id, null, true);
# --- select the current set
$this->request->user->setVar('current_set_id', $t_set->get("set_id"));
}
}
if ($t_set) {
$pn_item_id = null;
$pn_object_id = $this->request->getParameter('object_id', pInteger);
if ($pn_object_id) {
if (!$t_set->isInSet("ca_objects", $pn_object_id, $t_set->get("set_id"))) {
if ($pn_item_id = $t_set->addItem($pn_object_id, array(), $this->request->getUserID())) {
//
// Select primary representation
//
$t_object = new ca_objects($pn_object_id);
$vn_rep_id = $t_object->getPrimaryRepresentationID();
// get representation_id for primary
$t_item = new ca_set_items($pn_item_id);
$t_item->addSelectedRepresentation($vn_rep_id);
// flag as selected in item vars
$t_item->update();
$va_errors = array();
$this->view->setVar('message', _t("Successfully added item."));
$this->render("Form/reload_html.php");
} else {
$va_errors["message"] = _t('Could not add item to lightbox');
$this->render("Form/reload_html.php");
}
} else {
$this->view->setVar('message', _t("Item already in lightbox."));
$this->render("Form/reload_html.php");
}
} else {
$this->view->setVar('message', _t("Object ID is not defined"));
$this->render("Form/reload_html.php");
}
}
}
示例2: addItem
/**
*
*/
public function addItem()
{
global $g_ui_locale_id;
// current locale_id for user
if (!$this->request->isLoggedIn()) {
$this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form'));
return;
}
if (!($t_set = $this->_getSet(__CA_SET_EDIT_ACCESS__))) {
if ($t_set = $this->_getSet(__CA_SET_READ_ACCESS__)) {
$this->view->setVar('message', _t("You can not add items to this set. You have read only access."));
$this->index();
return;
}
# --- if there is not a set for this user, make a new set for them
$t_new_set = new ca_sets();
$vn_new_set_id = null;
$t_new_set->setMode(ACCESS_WRITE);
$t_new_set->set('access', 0);
$t_new_set->set('table_num', 57);
// 57=ca_objects
$t_list = new ca_lists();
$vn_set_id = $t_list->getItemIDFromList('set_types', $this->request->config->get('user_set_type'));
$t_new_set->set('type_id', $vn_set_id);
$t_new_set->set('user_id', $this->request->getUserID());
$t_new_set->set('set_code', $this->request->getUserID() . '_' . time());
// create new attribute
$t_new_set->insert();
if (!$t_new_set->numErrors()) {
if ($vn_new_set_id = $t_new_set->getPrimaryKey()) {
$t_new_set->addLabel(array('name' => _t("Your first lightbox")), $g_ui_locale_id, null, true);
// select the current set
$this->request->user->setVar('current_set_id', $vn_new_set_id);
//clear t_new_set object so form appears blank and load t_set so edit form is populated
$t_new_set = new ca_sets();
$t_set = new ca_sets($vn_new_set_id);
}
}
}
if (!$t_set) {
$va_errors[] = _t('Could not create lightbox for user');
} else {
$pn_item_id = null;
$pn_object_id = $this->request->getParameter('object_id', pInteger);
if (!$t_set->isInSet("ca_objects", $pn_object_id, $t_set->get("set_id"))) {
if ($pn_item_id = $t_set->addItem($pn_object_id, array(), $this->request->getUserID())) {
//
// Select primary representation
//
$t_object = new ca_objects($pn_object_id);
$vn_rep_id = $t_object->getPrimaryRepresentationID();
// get representation_id for primary
$t_item = new ca_set_items($pn_item_id);
$t_item->addSelectedRepresentation($vn_rep_id);
// flag as selected in item vars
$t_item->update();
$va_errors = array();
$this->view->setVar('message', _t("Successfully added item. %1Click here to resume your search%2.", "<a href='" . caNavUrl($this->request, "Detail", "Object", "Show", array("object_id" => $pn_object_id)) . "'>", "</a>"));
} else {
$va_errors[] = _t('Could not add item to lightbox');
}
} else {
$this->view->setVar('message', _t("Item already in set. %1Click here to resume your search%2.", "<a href='" . caNavUrl($this->request, "Detail", "Object", "Show", array("object_id" => $pn_object_id)) . "'>", "</a>"));
}
}
//$t_row = new ca_objects($pn_object_id);
$this->view->setVar('errors', $va_errors);
$this->index();
}