本文整理汇总了PHP中Jaws_ORM::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_ORM::getInstance方法的具体用法?PHP Jaws_ORM::getInstance怎么用?PHP Jaws_ORM::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jaws_ORM
的用法示例。
在下文中一共展示了Jaws_ORM::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NewTerm
/**
* Adds a new term
*
* @acess public
* @param string $term Term
* @param string $fast_url
* @param string $desc Term's description
* @return mixed Returns true if term was added or Jaws_Error on error
*/
function NewTerm($term, $fast_url, $desc)
{
$fast_url = empty($fast_url) ? $term : $fast_url;
$fast_url = $this->GetRealFastUrl($fast_url, 'glossary');
$now = Jaws_DB::getInstance()->date();
$params['term'] = $term;
$params['fast_url'] = $fast_url;
$params['description'] = $desc;
$params['createtime'] = $now;
$params['updatetime'] = $now;
$glossaryTable = Jaws_ORM::getInstance()->table('glossary');
$result = $glossaryTable->insert($params)->exec();
if (Jaws_Error::IsError($result)) {
$GLOBALS['app']->Session->PushLastResponse(_t('GLOSSARY_ERROR_TERM_NOT_CREATED'), RESPONSE_ERROR);
return new Jaws_Error(_t('GLOSSARY_ERROR_TERM_NOT_CREATED'));
}
$GLOBALS['app']->Session->PushLastResponse(_t('GLOSSARY_TERM_ADDED'), RESPONSE_NOTICE);
$glossaryTable = Jaws_ORM::getInstance()->table('glossary');
$row = $glossaryTable->select('id:integer')->where('createtime', $now)->fetchRow();
if (Jaws_Error::IsError($row)) {
$GLOBALS['app']->Session->PushLastResponse(_t('GLOSSARY_ERROR_TERM_NOT_CREATED'), RESPONSE_ERROR);
return new Jaws_Error(_t('GLOSSARY_ERROR_TERM_NOT_CREATED'));
}
if (isset($row['id'])) {
return $row['id'];
}
return false;
}
示例2: Upgrade
/**
* Upgrades the gadget
*
* @access public
* @param string $old Current version (in registry)
* @param string $new New version (in the $gadgetInfo file)
* @return mixed True on success, Jaws_Error otherwise
*/
function Upgrade($old, $new)
{
if (version_compare($old, '2.0.0', '<')) {
$variables = array();
$variables['logon_hours'] = str_pad('', 42, 'F');
$result = $this->installSchema('schema.xml', $variables, '1.0.0.xml');
if (Jaws_Error::IsError($result)) {
return $result;
}
// update users passwords
$usersTable = Jaws_ORM::getInstance()->table('users');
$usersTable->update(array('password' => $usersTable->concat(array('{SSHA1}', 'text'), 'password')))->where($usersTable->length('password'), 32, '>')->exec();
$usersTable->update(array('password' => $usersTable->concat(array('{MD5}', 'text'), 'password')))->where($usersTable->length('password'), 32)->exec();
// ACL keys
$this->gadget->acl->insert('ManageFriends');
$this->gadget->acl->insert('AccessDashboard');
$this->gadget->acl->insert('ManageDashboard');
}
if (version_compare($old, '2.1.0', '<')) {
$this->gadget->registry->delete('anon_repetitive_email');
}
if (version_compare($old, '2.2.0', '<')) {
$result = $this->installSchema('schema.xml', '', '2.1.0.xml');
if (Jaws_Error::IsError($result)) {
return $result;
}
}
return true;
}
示例3: GetYearEvents
/**
* Fetches number of events per month
*
* @access public
* @param int $user User ID
* @return array Query result
*/
function GetYearEvents($user = null, $shared = null, $foreign = null, $year)
{
$table = Jaws_ORM::getInstance()->table('ec_events as events');
$jdate = Jaws_Date::getInstance();
$eventsByMonth = array();
for ($m = 1; $m <= 12; $m++) {
$table->reset();
$table->select('events.id');
$table->join('ec_recurrences as recs', 'events.id', 'recs.event');
$table->join('ec_users', 'events.id', 'ec_users.event');
if ($user !== null) {
$table->where('ec_users.user', $user)->and();
}
if ($shared === true) {
$table->where('shared', true)->and();
$table->where('events.user', $user)->and();
}
if ($foreign === true) {
$table->where('ec_users.owner', $user, '<>')->and();
}
$daysInMonth = $jdate->monthDays($year, $m);
$start = $jdate->ToBaseDate($year, $m, 1);
$start = $GLOBALS['app']->UserTime2UTC($start['timestamp']);
$stop = $jdate->ToBaseDate($year, $m, $daysInMonth, 23, 59, 59);
$stop = $GLOBALS['app']->UserTime2UTC($stop['timestamp']);
$table->where('recs.start_time', $stop, '<')->and();
$table->where('recs.stop_time', $start, '>');
$table->groupBy('events.id');
$eventsByMonth[$m] = count($table->fetchAll());
}
return $eventsByMonth;
}
示例4: DeleteGroups
/**
* Delete many group
*
* @access public
* @returns array of Address Books or Jaws_Error on error
*/
function DeleteGroups($groups, $user)
{
$agModel = $this->gadget->model->load('AddressBookGroup');
$agModel->DeleteAddressForGroups($groups, $user);
$aTable = Jaws_ORM::getInstance()->table('address_group');
return $aTable->delete()->where('user', (int) $user)->and()->where('id', $groups, 'in')->exec();
}
示例5: Execute
/**
* Returns an array with the results of a tag content
*
* @access public
* @param string $action Action name
* @param array $references Array of References
* @return array An array of entries that matches a certain pattern
*/
function Execute($action, $references)
{
if (empty($action) || !is_array($references) || empty($references)) {
return false;
}
$table = Jaws_ORM::getInstance()->table('blog');
$table->select('id:integer', 'fast_url', 'title', 'summary', 'text', 'updatetime');
$result = $table->where('id', $references, 'in')->fetchAll();
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$posts = array();
foreach ($result as $r) {
$post = array();
$post['title'] = $r['title'];
$post['url'] = $this->gadget->urlMap('SingleView', array('id' => $r['fast_url']));
$post['outer'] = false;
$post['image'] = 'gadgets/Blog/Resources/images/logo.png';
$post['snippet'] = $r['summary'];
$post['date'] = $date->ToISO($r['updatetime']);
$posts[$r['id']] = $post;
}
return $posts;
}
示例6: InsertContact
/**
* Sends email to user
*
* @access public
* @param string $name Name
* @param string $email Email address
* @param string $company
* @param string $url
* @param string $tel
* @param string $fax
* @param string $mobile
* @param string $address
* @param string $rcipient Rcipient ID
* @param string $subject Subject of message
* @param string $attachment Attachment filename
* @param string $message Message content
* @return bool True on Success or False on Failure
*/
function InsertContact($name, $email, $company, $url, $tel, $fax, $mobile, $address, $recipient, $subject, $attachment, $message)
{
$now = Jaws_DB::getInstance()->date();
$data = array();
$data['[user]'] = $GLOBALS['app']->Session->GetAttribute('user');
$data['ip'] = $_SERVER['REMOTE_ADDR'];
$data['name'] = $name;
$data['email'] = $email;
$data['company'] = $company;
$data['url'] = $url;
$data['tel'] = $tel;
$data['fax'] = $fax;
$data['mobile'] = $mobile;
$data['address'] = $address;
$data['recipient'] = (int) $recipient;
$data['subject'] = $subject;
$data['attachment'] = $attachment;
$data['msg_txt'] = $message;
$data['reply'] = '';
$data['reply_sent'] = 0;
$data['createtime'] = $now;
$data['updatetime'] = $now;
$cntctTable = Jaws_ORM::getInstance()->table('contacts');
$result = $cntctTable->insert($data)->exec();
if (Jaws_Error::IsError($result)) {
return false;
}
$GLOBALS['app']->Session->SetCookie('visitor_name', $name, 60 * 24 * 150);
$GLOBALS['app']->Session->SetCookie('visitor_email', $email, 60 * 24 * 150);
$GLOBALS['app']->Session->SetCookie('visitor_url', $url, 60 * 24 * 150);
return $result;
}
示例7: Execute
/**
* Fetches files having specific tag
*
* @access public
* @param string $action Action name
* @param array $references Array of References
* @return array An array of entries that matches a certain pattern
*/
function Execute($action, $references)
{
if (empty($action) || !is_array($references) || empty($references)) {
return false;
}
$table = Jaws_ORM::getInstance()->table('directory');
$table->select('id:integer', 'title', 'description', 'update_time');
$result = $table->where('hidden', false)->and()->where('id', $references, 'in')->fetchAll();
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$files = array();
foreach ($result as $r) {
$file = array();
$file['title'] = $r['title'];
$file['url'] = $this->gadget->urlMap('Directory', array('id' => $r['id']));
$file['outer'] = false;
$file['image'] = 'gadgets/Directory/Resources/images/logo.png';
$file['snippet'] = $r['description'];
$file['date'] = $date->ToISO($r['update_time']);
$files[$r['id']] = $file;
}
return $files;
}
示例8: GetMoblog
/**
* Get entries as Moblog
*
* @access public
* @return mixed Returns an array of phoo entries in moblog format and Jaws_Error on error
*/
function GetMoblog($album)
{
$table = Jaws_ORM::getInstance()->table('phoo_image_album');
$table->select('phoo_album_id', 'filename', 'phoo_image.id', 'phoo_image.title', 'phoo_image.description', 'phoo_image.createtime');
$table->join('phoo_image', 'phoo_image.id', 'phoo_image_album.phoo_image_id');
$table->join('phoo_album', 'phoo_album.id', 'phoo_image_album.phoo_album_id');
$table->where('phoo_image.published', true)->and();
$table->where('phoo_album.id', $album);
$table->orderBy('phoo_image.createtime desc');
$limit = $this->gadget->registry->fetch('moblog_limit');
if (Jaws_Error::isError($limit)) {
return new Jaws_Error(_t('PHOO_ERROR_GETMOBLOG'));
}
$result = $table->limit($limit)->fetchAll();
if (Jaws_Error::IsError($result)) {
return new Jaws_Error(_t('PHOO_ERROR_GETMOBLOG'));
}
foreach ($result as $key => $image) {
$result[$key]['name'] = $image['title'];
$result[$key]['thumb'] = $this->GetThumbPath($image['filename']);
$result[$key]['medium'] = $this->GetMediumPath($image['filename']);
$result[$key]['image'] = $this->GetOriginalPath($image['filename']);
$result[$key]['stripped_description'] = $image['description'];
}
return $result;
}
示例9: GetNumberOfEvents
/**
* Fetches number of total events
*
* @access public
* @param int $user User ID
* @return array Query result
*/
function GetNumberOfEvents($user = null, $query = null, $shared = null, $foreign = null, $start = null, $stop = null)
{
$table = Jaws_ORM::getInstance()->table('ec_events as event');
$table->select('count(event.id)');
$table->join('ec_users', 'event.id', 'event');
$table->join('users', 'owner', 'users.id');
if ($user !== null) {
$table->where('ec_users.user', $user)->and();
}
if ($shared === true) {
$table->where('shared', true)->and();
$table->where('event.user', $user)->and();
}
if ($foreign === true) {
$table->where('ec_users.owner', $user, '<>')->and();
}
if ($query !== null) {
$query = "%{$query}%";
$table->openWhere('subject', $query, 'like')->or();
$table->where('location', $query, 'like')->or();
$table->closeWhere('description', $query, 'like')->and();
}
$jdate = Jaws_Date::getInstance();
if (!empty($start)) {
$start = $jdate->ToBaseDate(preg_split('/[- :]/', $start), 'Y-m-d');
$start = $GLOBALS['app']->UserTime2UTC($start);
$table->where('stop_time', $start, '>')->and();
}
if (!empty($stop)) {
$stop = $jdate->ToBaseDate(preg_split('/[- :]/', $stop), 'Y-m-d');
$stop = $GLOBALS['app']->UserTime2UTC($stop);
$table->where('start_time', $stop, '<');
}
return $table->fetchOne();
}
示例10: Execute
/**
* Returns an array with the results of a tag content
*
* @access public
* @param string $action Action name
* @param array $references Array of References
* @return array An array of entries that matches a certain pattern
*/
function Execute($action, $references)
{
if (empty($action) || !is_array($references) || empty($references)) {
return false;
}
$sptTable = Jaws_ORM::getInstance()->table('static_pages_translation');
$sptTable->select('page_id:integer', 'group_id', 'title', 'content', 'language', 'fast_url', 'static_pages_translation.updated');
$sptTable->join('static_pages', 'static_pages.page_id', 'static_pages_translation.base_id');
$result = $sptTable->where('translation_id', $references, 'in')->fetchAll();
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$pages = array();
foreach ($result as $p) {
if (!$this->gadget->GetPermission('AccessGroup', $p['group_id'])) {
continue;
}
$page = array();
$page['title'] = $p['title'];
$url = $this->gadget->urlMap('Page', array('pid' => empty($p['fast_url']) ? $p['page_id'] : $p['fast_url'], 'language' => $p['language']));
$page['url'] = $url;
$page['image'] = 'gadgets/StaticPage/Resources/images/logo.png';
$page['snippet'] = $p['content'];
$page['date'] = $date->ToISO($p['updated']);
$pages[$p['page_id']] = $page;
}
return $pages;
}
示例11: Execute
/**
* Returns an array with the results of a tag content
*
* @access public
* @param string $action Action name
* @param array $references Array of References
* @return array An array of entries that matches a certain pattern
*/
function Execute($action, $references)
{
if (empty($action) || !is_array($references) || empty($references)) {
return false;
}
$table = Jaws_ORM::getInstance()->table('linkdump_links');
$table->select('id:integer', 'title', 'description', 'updatetime');
$result = $table->where('id', $references, 'in')->fetchAll();
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$links = array();
foreach ($result as $r) {
$link = array();
$link['title'] = $r['title'];
$link['url'] = $this->gadget->urlMap('Link', array('id' => $r['id']));
$link['outer'] = true;
$link['image'] = 'gadgets/LinkDump/Resources/images/logo.png';
$link['snippet'] = $r['description'];
$link['date'] = $date->ToISO($r['updatetime']);
$links[$r['id']] = $link;
}
return $links;
}
示例12: UpdateEventUsers
/**
* Updates users of a event
*
* @access public
* @param int $id Event ID
* @param array $users Set of User IDs
* @return mixed True or Jaws_Error
*/
function UpdateEventUsers($id, $users)
{
// Update shared status of the event
$shared = !empty($users);
$table = Jaws_ORM::getInstance()->table('ec_events');
$table->beginTransaction();
$table->update(array('shared' => $shared));
$res = $table->where('id', $id)->exec();
if (Jaws_Error::IsError($res)) {
return $res;
}
// Delete current users except owner
$uid = (int) $GLOBALS['app']->Session->GetAttribute('user');
$table = Jaws_ORM::getInstance()->table('ec_users');
$table->delete()->where('event', $id)->and();
$res = $table->where('user', $uid, '<>')->exec();
if (Jaws_Error::IsError($res)) {
return $res;
}
// Insert users
if (!empty($users)) {
foreach ($users as &$user) {
$user = array('event' => $id, 'user' => $user, 'owner' => $uid);
}
$table = Jaws_ORM::getInstance()->table('ec_users');
$table->reset();
$table->insertAll(array('event', 'user', 'owner'), $users);
$res = $table->exec();
if (Jaws_Error::IsError($res)) {
return $res;
}
}
$table->commit();
}
示例13: GetAlbumGroupsInfo
/**
* Get AlbumGroup list with group information
*
* @access public
* @param int $album Album ID
* @return mixed array with the groups or Jaws_Error on error
*/
function GetAlbumGroupsInfo($album)
{
$table = Jaws_ORM::getInstance()->table('phoo_album_group');
$table->select('phoo_album_group.group', 'phoo_group.name', 'phoo_group.fast_url');
$table->join('phoo_group', 'phoo_album_group.group', 'phoo_group.id');
$table->where('album', $album);
return $table->fetchAll();
}
示例14: UpdateFileUsers
/**
* Creates shortcuts of the file for passed users
*
* @access public
* @param int $id File ID
* @param array $users Users ID's
* @return mixed True or Jaws_Error
*/
function UpdateFileUsers($id, $users)
{
$table = Jaws_ORM::getInstance()->table('directory');
// Fetch file info
$table->select('is_dir:boolean', 'title', 'description', 'filename', 'filetype', 'filesize', 'url', 'updatetime', 'user', 'owner', 'reference', 'shared:boolean');
$file = $table->where('id', $id)->fetchRow();
if (Jaws_Error::IsError($file)) {
return $file;
}
// Fetch file users
$table->reset();
$table->select('user');
$table->where('reference', $id);
$current_users = $table->fetchColumn();
if (Jaws_Error::IsError($current_users)) {
return $current_users;
}
$old_ids = array_diff($current_users, $users);
$new_ids = array_diff($users, $current_users);
// Delete old shortcuts
if (!empty($old_ids)) {
$table->reset();
$table->delete();
$table->where('reference', $id)->and();
$table->where('user', $old_ids, 'in');
$res = $table->exec();
if (Jaws_Error::IsError($res)) {
return $res;
}
}
// Create new shortcuts
if (!empty($new_ids)) {
$shortcut = $file;
$shortcut['parent'] = 0;
$shortcut['shared'] = false;
$shortcut['reference'] = !empty($file['reference']) ? $file['reference'] : $id;
$shortcut['createtime'] = time();
foreach ($new_ids as $uid) {
$shortcut['user'] = $uid;
$table->reset();
$res = $table->insert($shortcut)->exec();
if (Jaws_Error::IsError($res)) {
return $res;
}
}
}
// Update `shared` status
$shared = !empty($users);
if ($file['shared'] !== $shared) {
$table->reset();
$table->update(array('shared' => $shared));
$res = $table->where('id', $id)->exec();
if (Jaws_Error::IsError($res)) {
return $res;
}
}
return true;
}
示例15: GetTerms
/**
* Get a list of all the terms
*
* @access public
* @return mixed Returns an array with all the terms or Jaws_Error on error
*/
function GetTerms()
{
$glossaryTable = Jaws_ORM::getInstance()->table('glossary');
$result = $glossaryTable->select('id:integer', 'user_id:integer', 'term', 'fast_url', 'description', 'updatetime')->orderBy('term')->fetchAll();
if (Jaws_Error::IsError($result)) {
return new Jaws_Error($result->getMessage());
}
return $result;
}