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


PHP Forum::delete方法代码示例

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


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

示例1: deleteForum

 public function deleteForum(Forum $forum)
 {
     $forum->delete();
     Cache::flush();
     return Redirect::to('dashboard/storyteller/manage/forums');
 }
开发者ID:AcceptableIce,项目名称:Larp3,代码行数:6,代码来源:StorytellerForumController.php

示例2: run

 function run($request)
 {
     set_time_limit(0);
     // check to see if this has been run before. If it has then we will have already
     // have removed the parentID field
     $checkForMigration = DB::query("SHOW COLUMNS FROM \"Post\"")->column();
     if (!in_array('ParentID', $checkForMigration)) {
         echo "Script has already ran. You can only run the migration script once.\n";
         return false;
     }
     // go through all the posts with a parent ID = 0 and create the new thread objects
     $oldThreads = DB::query("SELECT * FROM \"Post\" WHERE \"ParentID\" = '0'");
     if ($oldThreads) {
         $toCreateTotal = $oldThreads->numRecords();
         echo "Creating " . $toCreateTotal . " new Forum Threads \n";
         $holder = DataObject::get_one("ForumHolder");
         if (!$holder) {
             return user_error('No Forum Holder Found', E_USER_ERROR);
         }
         $failbackForum = new Forum();
         $failbackForum->Title = "Unimported Threads";
         $failbackForum->ParentID = $holder->ID;
         $failbackForum->write();
         $needsFailback = false;
         $totalThreadsSuccessfulCount = 0;
         $totalThreadsErroredCount = 0;
         while ($oldThread = $oldThreads->nextRecord()) {
             $hasError = false;
             $thread = new ForumThread();
             if (isset($oldThread['Title'])) {
                 $thread->Title = $oldThread['Title'];
             } else {
                 $hasError = true;
                 $thread->Title = "Question";
             }
             $thread->NumViews = isset($oldThread['NumViews']) ? $oldThread['NumViews'] : 0;
             $thread->IsSticky = isset($oldThread['IsSticky']) ? $oldThread['IsSticky'] : false;
             $thread->IsReadOnly = isset($oldThread['IsReadOnly']) ? $oldThread['IsReadOnly'] : false;
             $thread->IsGlobalSticky = isset($oldThread['IsGlobalSticky']) ? $oldThread['IsGlobalSticky'] : false;
             if (isset($oldThread['ForumID'])) {
                 $thread->ForumID = $oldThread['ForumID'];
             } else {
                 $hasError = true;
                 $needsFailback = true;
                 $thread->ForumID = $failbackForum->ID;
             }
             $thread->write();
             echo "Converted Thread: {$thread->ID} - {$thread->Title}. \n";
             // update all the children
             DB::query("\n\t\t\t\t\tUPDATE \"Post\" \n\t\t\t\t\tSET \"ThreadID\" = '{$thread->ID}', \"ForumID\" = '{$thread->ForumID}'\n\t\t\t\t\tWHERE \"TopicID\" = '" . $oldThread['ID'] . "'\n\t\t\t\t");
             if (!$hasError) {
                 $totalThreadsSuccessfulCount++;
             } else {
                 $totalThreadsErroredCount++;
             }
         }
     }
     echo "Converted {$totalThreadsSuccessfulCount} threads. Could not import {$totalThreadsErroredCount} threads.<br />";
     if (!$needsFailback) {
         $failbackForum->delete();
     } else {
         echo "Incorrectly imported threads are available to self moderate at <a href='" . $failbackForum->Link() . "'>here</a><br />";
     }
     // transfer subscriptions
     // was a rename table but mysql had locking issues.
     $subscriptions = DB::query("SELECT * FROM \"Post_Subscription\"");
     $subCount = 0;
     if ($subscriptions) {
         while ($sub = $subscriptions->nextRecord()) {
             // don't import really odd data
             if (isset($sub['TopicID']) && isset($sub['MemberID'])) {
                 $subCount++;
                 $threadSub = new ForumThread_Subscription();
                 $threadSub->ThreadID = $sub['TopicID'];
                 $threadSub->MemberID = $sub['MemberID'];
                 $threadSub->write();
             }
         }
     }
     echo "Transferred {$subCount} Thread Subscriptions<br />";
     // Update the permissions on the forums. The Posters, Viewers have changed from a int field
     // to an actual modelled relationship
     $forums = DataObject::get('Forum');
     if ($forums) {
         foreach ($forums as $forum) {
             $forum->ForumPostersGroupID = DB::query("SELECT \"ForumPostersGroup\" FROM \"Forum\" WHERE \"ID\" = '{$forum->ID}'")->value();
             if ($viewingGroup = DB::query("SELECT \"ForumViewersGroup\" FROM \"Forum\" WHERE \"ID\" = '{$forum->ID}'")->value()) {
                 $forum->ViewerGroups()->add(DataObject::get_by_id('Group', $viewingGroup));
             }
             $forum->write();
         }
     }
     // cleanup task. Delete old columns which are hanging round
     DB::dontRequireField('Post', 'ParentID');
     DB::dontRequireField('Post', 'TopicID');
     DB::dontRequireField('Post', 'Title');
     DB::dontRequireField('Post', 'NumViews');
     DB::dontRequireField('Post', 'IsSticky');
     DB::dontRequireField('Post', 'IsReadOnly');
     DB::dontRequireField('Post', 'IsGlobalSticky');
//.........这里部分代码省略.........
开发者ID:RyeDesigns,项目名称:silverstripe-forum,代码行数:101,代码来源:ForumMigrationTask.php

示例3: delete

 function delete($sure, $really_sure, $really_really_sure)
 {
     if (!$sure || !$really_sure || !$really_really_sure) {
         $this->setMissingParamsError();
         return false;
     }
     if ($this->getID() == $GLOBALS['sys_news_group'] || $this->getID() == 1 || $this->getID() == $GLOBALS['sys_stats_group'] || $this->getID() == $GLOBALS['sys_peer_rating_group']) {
         $this->setError(_('Cannot Delete System Group'));
         return false;
     }
     $perm =& $this->getPermission(session_get_user());
     if (!$perm || !is_object($perm)) {
         $this->setPermissionDeniedError();
         return false;
     } elseif ($perm->isError()) {
         $this->setPermissionDeniedError();
         return false;
     } elseif (!$perm->isSuperUser()) {
         $this->setPermissionDeniedError();
         return false;
     }
     db_begin();
     //
     //	Remove all the members
     //
     $members =& $this->getMembers();
     for ($i = 0; $i < count($members); $i++) {
         $this->removeUser($members[$i]->getID());
     }
     //
     //	Delete Trackers
     //
     $atf = new ArtifactTypeFactory($this);
     $at_arr =& $atf->getArtifactTypes();
     for ($i = 0; $i < count($at_arr); $i++) {
         if (!is_object($at_arr[$i])) {
             printf(_("Not Object: ArtifactType: %d"), $i);
             continue;
         }
         $at_arr[$i]->delete(1, 1);
     }
     //
     //	Delete Forums
     //
     $ff = new ForumFactory($this);
     $f_arr =& $ff->getForums();
     for ($i = 0; $i < count($f_arr); $i++) {
         if (!is_object($f_arr[$i])) {
             printf(_("Not Object: Forum: %d"), $i);
             continue;
         }
         $f_arr[$i]->delete(1, 1);
         //echo 'ForumFactory'.db_error();
     }
     //
     //	Delete Subprojects
     //
     $pgf = new ProjectGroupFactory($this);
     $pg_arr =& $pgf->getProjectGroups();
     for ($i = 0; $i < count($pg_arr); $i++) {
         if (!is_object($pg_arr[$i])) {
             printf(_("Not Object: ProjectGroup: %d"), $i);
             continue;
         }
         $pg_arr[$i]->delete(1, 1);
         //echo 'ProjectGroupFactory'.db_error();
     }
     //
     //	Delete FRS Packages
     //
     //$frspf = new FRSPackageFactory($this);
     $res = db_query("SELECT * FROM frs_package WHERE group_id='" . $this->getID() . "'");
     //echo 'frs_package'.db_error();
     //$frsp_arr =& $frspf->getPackages();
     while ($arr = db_fetch_array($res)) {
         //if (!is_object($pg_arr[$i])) {
         //	echo "Not Object: ProjectGroup: ".$i;
         //	continue;
         //}
         $frsp = new FRSPackage($this, $arr['package_id'], $arr);
         $frsp->delete(1, 1);
     }
     //
     //	Delete news
     //
     $news_group =& group_get_object($GLOBALS['sys_news_group']);
     $res = db_query("SELECT forum_id FROM news_bytes WHERE group_id='" . $this->getID() . "'");
     for ($i = 0; $i < db_numrows($res); $i++) {
         $Forum = new Forum($news_group, db_result($res, $i, 'forum_id'));
         if (!$Forum->delete(1, 1)) {
             printf(_("Could Not Delete News Forum: %d"), $Forum->getID());
         }
     }
     $res = db_query("DELETE FROM news_bytes WHERE group_id='" . $this->getID() . "'");
     //
     //	Delete docs
     //
     $res = db_query("DELETE FROM doc_data WHERE group_id='" . $this->getID() . "'");
     //echo 'doc_data'.db_error();
     $res = db_query("DELETE FROM doc_groups WHERE group_id='" . $this->getID() . "'");
//.........这里部分代码省略.........
开发者ID:neymanna,项目名称:fusionforge,代码行数:101,代码来源:Group.class.php

示例4: admin_destroy_forum

 public function admin_destroy_forum()
 {
     if (!isset($_POST['id'])) {
         error(__("Error"), __("No forum ID specified.", "discuss"));
     }
     if (!isset($_POST['hash']) or $_POST['hash'] != Config::current()->secure_hashkey) {
         show_403(__("Access Denied"), __("Invalid security key."));
     }
     $forum = new Forum($_POST['id']);
     if ($forum->no_results) {
         error(__("Error"), __("Invalid forum ID specified.", "discuss"));
     }
     if (!$forum->deletable()) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this forum.", "discuss"));
     }
     foreach ($forum->topics as $topic) {
         $topic->update(null, null, $_POST['move_forum']);
     }
     Forum::delete($forum->id);
     Flash::notice(__("Forum deleted.", "discuss"), "/admin/?action=manage_forums");
 }
开发者ID:vito,项目名称:chyrp-site,代码行数:21,代码来源:discuss.php


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